Hi guys,
I have made a text scroller in flash however I can not get the text to scoll on my desired trajectory.
can anyone have a quick look at my AS and maybe advise me as to where I am going wrong.
here is the example I am working with:
//set my variable
targY = 0;
targY = 0;
//set the x position of my scroller
scroller._x = theMask._width;
//set the drag action of the scroller
//drag is restricted to the height of the mask
scroller.onPress = function() {
startDrag(this, false, this._x, 0, this._x, theMask._height-this._height);
};
//stop the drag
scroller.onRelease = scroller.onReleaseOutside=function () {
stopDrag();
};
//set the mask for the text
theText.setMask(theMask);
//the scrolling animation
theText.onEnterFrame = function() {
//set the scroll amount
yscrollAmount = (this._height-(theMask._height/1.3))/(theMask._height-dragger._height);
//set a new target y position
targY = -scroller._y*yscrollAmount;
//set the y of the text to 1/5 of the distance between its current y and the target y
this._y -= (this._y-targY)/5;
trace("yscrollAmount = " + yscrollAmount + " : scroller._y = " + scroller._y + " : targY = " + targY + " : this._y = " + this._y);
//set the scroll amount
xscrollAmount = (this._width-(theMask._width/1.3))/(theMask._width-dragger._width);
//set a new target y position
targY = -scroller._x*xscrollAmount;
//set the y of the text to 1/5 of the distance between its current y and the target y
this._y -= (this._x-targX)/5;
trace("xscrollAmount = " + xscrollAmount + " : scroller._y = " + scroller._y + " : targY = " + targY + " : this._x = " + this._x);
};
alternately I thought I would be able to achieve the same effect with a different script. I found this one on the internet, am trying to modify atm.
//+++++++++++++++++++++++++++++++++++++++++++ slider
scroller.onPress = function () {
this.startDrag(false,3,14,3,116);
}
scroller.onRelease = function () {
this.stopDrag();
}
scroller.onRollOver = function () {
this.nextFrame();
}
scroller.onRollOut = function () {
this.prevFrame();
}
scroller.onEnterFrame = function () {
_parent.info._y = -this._y-30;
}
//+++++++++++++++++++++++++++++++++++++++++++ down
down.onRollOver = function () {
this.nextFrame();
}
down.onRollOut = function () {
this.prevFrame();
}
down.onRelease = function () {
if(scroller._y+5<115) {
scroller._y+=5;
} else {
scroller._y = 115;
}
}
//+++++++++++++++++++++++++++++++++++++++++++ up
up.onRollOver = function () {
this.nextFrame();
}
up.onRollOut = function () {
this.prevFrame();
}
up.onRelease = function () {
if(scroller._y-5>13) {
scroller._y-=5;
} else {
scroller._y = 13;
}
}
//+++++++++++++++++++++++++++++++++++++++++++ sliderBg
sliderBg.onPress = function () {
if(this._ymouse>13 && this._ymouse<116) {
scroller._y = this._ymouse;
}
}
sliderBg.useHandCursor=false;