p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Flash (all versions) (http://p2p.wrox.com/flash-all-versions-59/)
-   -   how to move movieclips using code in AS 2.0 (http://p2p.wrox.com/flash-all-versions/82131-how-move-movieclips-using-code-2-0-a.html)

yujhkgit January 5th, 2011 11:33 AM

how to move movieclips using code in AS 2.0
 
to move a movieclip in flash using code it is very simple, give the instance name of char (or any other name, but you will have to change the name in the code) to the movieclip you want to move.

open up the actions panel and click on your movieclip. now if you want to move the movieclip up with arrowkeys, copy&paste this code into the actions panel;

onClipEvent(enterFrame){

if(Key.isDown(Key.LEFT)){
_root.char._x-=10

// this can be copied&pasted, but do not copy the onClipEvent part
// don't forget that the y axis is reversed!
}
}

"char" is the instance name, and the _x can be changed to _y

dont forget to change it to RIGHT, UP, or DOWN


All times are GMT -4. The time now is 10:51 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.