View comments | RSS feed

MovieClip._rotation

Availability

Flash Player 4.

Usage

my_mc._rotation:Number

Description

Property; the rotation of the movie clip, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement my_mc._rotation = 450 is the same as my_mc._rotation = 90.

Example

The following example creates a movie clip instance dynamically, rotates, and loads an image into the instance.

this.createEmptyMovieClip("image_mc", 1);
image_mc._rotation = 15;
image_mc.loadMovie("http://www.macromedia.com/devnet/blueprint/articles/nielsen/spotlight_jnielsen.jpg");

See also

Button._rotation, TextField._rotation

Comments


No screen name said on Mar 26, 2005 at 1:57 PM :
The _rotation property seems to rotate along it's 0,0 point. How do I rotate a clip (created using createEmptyMovieClip) from it's center?
jaseinatl@gmail.com said on Mar 28, 2005 at 6:07 PM :
I think the author intended to demonstrate how the _rotation values change once _rotation exceeds 180 rather than 360.

In other words, using traditional rotations formulas, 450 degrees is the same as 90 degrees. This is also true in Flash, so it's not important. I think he meant to say that 225 degrees is the same as -45 degrees in Flash(which is a signifcant departure from what we are used to.)

In creating a spiral effect in Actionscript, it is important to account for the sudden change in polarity once your _rotation value exceeds 180.
[AS] //assume this code is part of the onEnterFrame declaration of the clip you want to spiral
//assume rotIncr is the amount to increment the rotation
//assume maxScale is the largest percentage scale you desire for the clip.
this._rotation+=rotIncr -(this._rotation>360-rotIncr?360:0);
this._xscale=this._yscale=maxScale*int(this._rotation/360);
[/AS]

because _rotation value becomes negative after 180 degrees, the previous spiral formula doesn't work--you end up with a tiny, distorted, negative-scaled clip (that by virtue of it's negative scale and negative rotation) appears to rotate correctly.

Anyways, thanks again for providing this forum and for all your hard work on Flash Documentation. Best wishes, Jase

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001550.html