AS Movement along a path
- Started
- Last post
- 4 Responses
- doddster
I'm trying to create a movie where clicking a button changes the X & Y positions of a target movieclip.
I have a way to do this, so that it animates to each position (as opposed to simply jumping to the new position).
However, what I would like to happen is for the animation to follow a path, as opposed to moving direct (as the crows flies, as it were) so that I can incoprorate extra design elements into the animation, as the finished piece will include around 10 target areas, which I would like to pass through.
I've done a diagram to hopefully explain what I mean better!
and a rough swf:
- joyride0
I was looking into this a couple years ago. I could not find a way via AS to attach a movieClip to a specific path based on selection. Things may have changed since mx. It seems like something that should be possible.
- Anarchitect0
use the new AS2.0 tween/transition class.
http://www.macromedia.com/devnet…create a listener to your tween class object, add an onMotionFinished event and trigger a sequential function:
if the tween has finished the first motion, [x = targetx && y = targety], initate the second motion.
- doddster0
thanks for your responses - I'll let you know how it goes...
- joyride0
Anarchitect: That could work. you're going to need to get the target x, y; current x, y; do the math, then send it down the _x then onMotionFinished, send it to _y... that make sense?
Sometimes I think a dynamic path would be so easy. Have multiple path names. then if(x) attach the (mc) to pathName