Name

MovieClip._rotation Property — rotation, in degrees, of a clip or movie

Availability

Flash 4 and later

Synopsis

mc._rotation

Access

Read/write

Description

The floating-point _rotation property specifies the number of degrees mc is rotated from its original orientation (if mc is a clip, the original orientation is that of its symbol in the Library). Both authoring tool and programmatic adjustments are reflected in _rotation. Numbers in the range to 180.0 rotate the clip clockwise. Numbers in the range to -180.0 rotate the clip counter-clockwise. 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 following calculation:

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

Bugs

In the Flash 4 Player, 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 whenever setting the _rotation.

Example

Placing the following code on a clip causes the ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.