In your scrolling window tutorial on this site I was wondering if you could explain to me what exactly this part of the code accomplishes?
MovieClip.prototype.move = function () {
dest = _root.xnew ;
pos = this._x ;
vel = (dest-pos)/7 ;
this._x += vel ;
}
I understand technically the code but I don’t understand its purpose exactly. Like this line vel = (dest-pos)/7; why are you dividing by 7, how does it apply. I don’t see how this code apply’s if you could explain this to me it would be great. Thanks Alot
You’re right, lost. The thing is: I want the clip to go to a certain destination (dest) with a decreasing speed. So I get the distance between the clip and the destination, dest-pos, and I increase the position of the clip by a fraction of that distance.
Doing so, you see that on the next enterFrame, dest-pos will have decreased, so you’ll add less and so on and so on, until it reaches the destination.
And 7 is arbitrary. You’re free to change that value to see what it does (1 means direct jump and a big number means no motion).