MovieClip._rotation Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
MovieClip._rotation Property Flash 4

rotation, in degrees, of a clip or movie read/write
mc._rotation

Description

The floating-point _rotation property specifies the number of degrees mc is rotated from its original orientation (if mc is not a main movie, the original orientation is that of mc's symbol in the Library). Both authoring-time and programmatic adjustments are reflected in _rotation. Numbers in the range of 0 to 180.0 rotate the clip clockwise. Numbers in the range of 0 to -180.0 rotate the clip counterclockwise. The same effect is achieved when rotating a clip n degrees or n-360 degrees (where n is positive). For example, there is no difference between rotating a clip +299.4 degrees or -60.6 degrees. Likewise, when n is negative, there is no difference between n degrees and n+360 degrees. For example, rotating a clip -90 degrees is the same as rotating it +270 degrees.

When _rotation is set to anything outside the range of -180 to 180, the value is brought into the proper range according to the equivalent of the following calculation:

x = newRotation % 360; if (x > 180) {   x -= 360; } else if (x < -180) {   x += 360; } _rotation = x;

Bugs

In Flash Player 4, setting the _rotation of a clip reduces the scale of that clip by a fractional amount. Over many _rotation settings, a clip will actually shrink noticeably. To account for this bug, set the _xscale and _yscale of the clip to 100 (or whatever their previous values are) whenever setting the _rotation.

Example

The following onEnterFrame( ) handler causes the box_mc clip to rotate 5 degrees clockwise each time a frame is rendered:

box_mc.onEnterFrame = function {   this._rotation += 5; }


    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net