Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Movie Clip rotation

Status
Not open for further replies.

martinb7

Programmer
Jan 5, 2003
235
GB
Hi, how do you make a movie clip rotate using actionscript?

e.g

A speed dial:

when the speed increases, how would you make the pointer turn to point to the the numbers around the side matching the speed in a dynamic text box??

Any ideas?

Thanx

Martin
 
Rotation works in degrees so this will rotate a clip 10 degrees clockwise:

myMovieClip._rotation+=10

To make it line up with a dial or display just work out how far round the dial you need it to go in degrees and add the value on.
 
yes, but how do you match the rotation to the numbers on the speedometer if the value is coming from a text box??
 
You just have to work out where the numbers lie on the circumference of the circle in relation to the value you have is the textbox.

For instance - you have numbers 1 to 10 as he values that may appear in the textbox and ten points around the circle that forms your readout.

360 degrees in a circle so to go to the right value on the dial you'd have this code:

meter._rotation=myTextBoxValue*(360/10)

If it's a constant readout you'd have to put the whole thing into a frame by frame event:

this.onEnterFrame=function(){
meter._rotation=myTextBoxValue*(360/10)
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top