Speeding Object rotation with two buttons |
|
6.7.2009, 12:26 Total views: 7969
Using this thoroughly explained, detailed action script 3 flash lesson, you will see how to create speeding object rotation effect using two buttons. You can use this effect for some flash banner, or for some presentation. Using this lesson, you will also learn how to convert any object into a Movie Clip Symbol, how to create instance name and much more.
Example:
Click on the right button to speed up the object rotation!
Step 1
Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the dimensions of your document as whatever you like. Select any color as background color. Set your Flash movie's frame rate to 32 and click ok.
Step 2
Draw any object or import any photo into a flash stage which you like to use for this lesson
Step 3
While the object or photo is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.

Step 4
While the new made Movie Clip is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip object_mc. See the picture below!

Step 5
Create now two buttons, left and right. After that, select just left button and go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this button leftBtn. See the picture below!

Step 6
Select now just right button and go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this button rightBtn. See the picture below!

Step 7
Select now the first frame of layer buttons and go to the AS panel (F9). After that, enter this code inside the actions panel:
var speed:int = 10; object_mc.addEventListener(Event.ENTER_FRAME, wheelRoll); function wheelRoll(event:Event):void { event.target.rotation += speed; } leftBtn.addEventListener(MouseEvent.CLICK, wheelBack); rightBtn.addEventListener(MouseEvent.CLICK, wheelForward); function wheelBack(Event:MouseEvent):void { trace(speed); } function wheelForward(Event:MouseEvent):void { speed ++; trace(speed); }
We're done now!
Test your movie and enjoy!
Download source file (.fla)
|
 |
|
|
|
Related links
|
 |
|