Ejemplo de implementar un scroll tipo barra desplazadora.
//set a variable
targY = 0;
//set the x position of the dragger_mc
dragger_mc._x = mascara_mc._width+10;
fondo_scroll_mc._x = dragger_mc._x;
//set the drag action of the dragger_mc
//drag is restricted to the height of the mask
dragger_mc.onPress = function() {
startDrag(this, false, this._x, 0, this._x, mascara_mc._height-this._height);
};
//stop the drag
dragger_mc.onRelease = dragger_mc.onReleaseOutside=function () {
stopDrag();
};
//set the mask for the text
listado_mc.setMask(mascara_mc);
//the scrolling animation
if (listado_mc._height>mascara_mc._height) {
listado_mc.onEnterFrame = function() {
/*set a variable
this variable basically stores info regarding what fraction of the total text
is being displayed through the mask and ensures that dragging the dragger_mc
from top to bottom will reveal all the text.
this allows you to change the amount of text and the scroller will update itself
*/
scrollAmount = (this._height-(mascara_mc._height/1.3))/(mascara_mc._height-dragger_mc._height);
//set a new target y position
targY = -dragger_mc._y*scrollAmount;
//set the y of the text to 1/5 of the distance between its current y and the target y
//change the 5 to a lower number for faster scrolling or a higher number for slower scrolling
this._y -= (this._y-targY)/7;
};
} else {
dragger_mc._visible = false;
fondo_scroll_mc._visible = false;
}
fondo_scroll_mc.useHandCursor = false;
fondo_scroll_mc.onPress = function() {
if (_xmouse-200<fondo_scroll_mc._height-dragger_mc._height) {
dragger_mc._y = _ymouse;
if(dragger_mc._y>fondo_scroll_mc._height-dragger_mc._height){
dragger_mc._y=fondo_scroll_mc._height-dragger_mc._height;
}
} else {
dragger_mc._y = fondo_scroll_mc._height-dragger_mc._height;
}
};
