-
Movement with easing
In a presentation (Flash MX. Mac) a movie clip shall move from one place to another on the stage with very smooth easing before stopping. I usually do that with a tween on the timeline. But now I would like to get that in a script in a key frame instead on the timeline, for a smother movement, I hope, and I will reuse this many times in the presentation. So now I wonder if someone out there can show me how to write that script, please?
-
Space Monkey
calculate the distance between startpoint and targetpoint, then add this distance divided by an easing factor to the current position
of your mc
main Timeline:
code:
//define values
//startpoint is whereever you place the moviclip myMC
startpoint = myMC._x;
//define a target position
targetpoint = 220;
//the easing factor, lower values=faster movement
easeme = 12;
//the easing function
myMC.onEnterFrame = function() {
//calculate distance
dist = Math.round(targetpoint-this._x);
//add distance divided by factor
this._x += dist/easeme;
if (dist == 0) {
//at the position, kill on enterFrame
trace("here");
delete this.onEnterFrame;
}
};
:::i am jacks complete lack of surprise:::
-
-
All you need to know about easing equations can be found here:
http://www.robertpenner.com/easing/
enjoy!
-
Yes, you are right there is all you need to know. Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|