Table of Contents

MovieClip._y Property Flash 4

vertical location of a clip or movie, in pixels read/write
mc._y

Description

The floating-point _y property always indicates the vertical position of mc's registration point, but it is measured relative to one of three possible coordinate spaces:

The _y property (along with all vertical coordinates in Flash) increases downward and decreases upward�the opposite of the Cartesian coordinate system. Fractional _y values are approximated in Flash with antialiasing (blurring). Flash's basic unit of measure is a twentieth of a pixel (a "twip"), so the shortest distance a clip can be moved vertically is .05 pixels. Smaller increments are ignored:

trace(ball_mc._y);    // Displays: 0
ball_mc._y += .01;
trace(ball_mc._y);    // Still displays 0. The assignment had no effect.

If mc is contained by an instance that is scaled and/or rotated, the coordinate space it inhabits is also scaled and/or rotated. For example, if mc's parent is scaled by 200% and rotated 90 degrees clockwise, _y will increase toward the left rather than downward, and a single unit of _y will actually be 2 pixels instead of 1.

Because switching between instance and main movie coordinate spaces can be cumbersome, the MovieClip object provides the localToGlobal( ) and globalToLocal( ) methods for performing coordinate-space transformations.

Example

The following onEnterFrame( ) handler causes ball_mc to move down 5 pixels with each passing frame (assuming that its coordinate space hasn't been altered by transformations to its parent):

ball_mc.onEnterFrame = function () {
  this._y += 5;
}

See Also

MovieClip.globalToLocal( ), MovieClip.localToGlobal( ), MovieClip._x


Table of Contents