Quantunet.com

Flash QuickSkills

2D Position Tween  

Download this .fla

How to create a 2D motion tween.

Actionscript

onClipEvent(enterFrame){
this._x += 10;
this._y += 20;
}


Note:
Press the "refresh" button in the browser to play the animation again.

// As the actionscript is put inside the mc, "this" refers the the mc on the timeline the code is in.
// So by association references the the mc "mc1" as it is inside it.


onClipEvent(enterFrame){
this._x += 10;
this._y += 20;
}


// The code "_x +=10 " adds 10 pixels to the x position and "_y+=20" adds 20 piexels to the y position of the movie clip.
// Since both of these commands are inside the "onClipEvent(enterFrame)" function it is called every time the animation
// enters a new frame.

// The code when viewed as a whole tells the movie clip it is inside the move 10 pixels to the right and 20 pixels down
// every time the movie enters a new frame creating 2d motion.

© 2005 - 2007 Quantunet.com All Rights Reserved
Home | Terms of Use | Contact Us