Table of Contents

TextField._y Property Flash 6

vertical location of the text field, in pixels read/write
theField._y

Description

The floating-point _y property indicates the vertical position of theField's top border. It is measured relative to one of two possible coordinate spaces:

The _y property (as with all vertical coordinates in Flash) increases downwards and decreases upwards�the opposite of the Cartesian coordinate system. Fractional _y values are approximated in Flash with antialiasing (blurring).

If theField 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 theField's parent is scaled by 200% and rotated 90 degrees clockwise, _y increases toward the left, rather than downward, and a single unit of _y is 2 pixels instead of 1.

Example

The _y property is often used in conjunction with _height to programmatically space or align text fields stacked vertically, as shown in the function makeFields( ):

// Try it out...
makeFields(this, 6, 5, 100, 100, 200, 20);
// Make a series of text fields
function makeFields (clip, numFields, bufferSpace, startX, startY, width, height) {
  // Loop to make the requested fields
  for (var i = 0; i < numFields; i++) {
    // Make the current field
    clip.createTextField("field" + i + "_txt", i+1, startX, startY, width, height);
    // Store a reference to the current field
    var thisField = clip["field" + i + "_txt"];
    // Turn on border and input
    thisField.border = true;
    thisField.type = "input";
    // Position the current field if it's not the first
    if (i > 0) {
      var prevField = clip["field" + (i-1) + "_txt"];
      thisField._y = prevField._y + prevField._height + bufferSpace;
    }
  }
}

See Also

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


Table of Contents