Recipe 1.34. Positioning Elements Precisely


Problem

You want to position elements with numeric precision.

Solution

Set the element's X and Y coordinates in the Property inspector.

Discussion

Every element in Flash, whether it is hand-drawn artwork or a movie clip symbol, has a single registration point, which represents the location of the element. Though an element can be as large as you want, its registration point is always a single dot, a twentieth of a pixel in size.

When you position an element on stage, its X, Y coordinate is the location of its registration point. Using the X and Y fields of the Property inspector, you can specify the position for the selected element with numeric precision. (Remember that the stage's origin, [0,0], is in its upper-left corner.) Positioning with numeric precision is useful when you want to lay out elements of an animation over time, space elements out according to a mathematical pattern, or make room for elements created at runtime using ActionScript.

The location of an element's registration point can vary. For artwork that you've drawn using Flash tools, the registration point is always the upper-left corner of the element. Thus, if an element is positioned at 0,0, then its upper-left corner coincides with the upper-left corner of the stage. Other Flash elements, including symbols by default, have registration points at the center. For these elements, a positioning of 0,0 means that their centers are aligned with the upper-left corner of the stage, and that some of their contents are likely offstage.




Flash 8 Cookbook
Flash 8 Cookbook (Cookbooks (OReilly))
ISBN: 0596102402
EAN: 2147483647
Year: 2007
Pages: 336
Authors: Joey Lott

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