This tutorial will show you how to rotate any object on click, using the Action Script code. For this tutorial I will use bmw logo.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! Let's start!
Example:
Step 1
Create a new flash document, press Ctrl+J on the keyboard (Document Properties) and set Width to 300 and Height to 250px. Frame rate set to 40fps (Frames per Second).

Step 2
Open any object that you want to spin, or draw some object. For this example I will draw bmw logo. See the picture below.

Step 3
Select that object and press F8 on the keyboard (Convert to Symbol) to convert it into a Movie Clip.

Step 4
While your new made Movie Clip (object) is still selected, open the Properties Panel (Ctrl+F3), and under type object. See the picture below!

Step 5
Insert a new layer, take the Text Tool (T) and type somewhere on the stage SPIN. Look at the picture below!

Step 6
Insert a new layer and name it invisible button. Then, take the Rectangle Tool (R) and draw a "rectangle" on the place where you have wrote SPIN.
Step 7
While your "rectangle" is still selected, press F8 on the keyboard (Convert to Symbol) and convert it into a Button.
Step 8
Double click on a new made button, or choose right click and Edit in Place.

Step 9
Then, do like it is shown on the picture below.

Step 10
Go back on main scene ( Scene1 ), select the button, open the Action Script Panel (F9), and paste this script:
on(press){
object.spinning = true
object.spin = 12 + Math.random()*20
object._rotation = object._rotation = 0
}
Step 11
Select the object (in my example bmw logo) open the Action Script Panel (F9) and paste this script:
onClipEvent(enterFrame){
if (spinning){
if (spin <= 0){
spinning = false
rot = (_rotation < 0) ? 180 + _rotation : _rotation
_root.youSpunA = Math.floor(16 * rot/180)+1
}else{
_rotation += spin -= .25
_parent.wheel._rotation = -_rotation
}
}
}
We're done!
Cheers!
Download source file (.fla)