PDA

View Full Version : find registration point


werehunt
08-20-2009, 12:33 PM
if i have a movieclip or a sprite could i find (via code) where is its registration point compared to its top left point (no rotation included) ?

senocular
08-20-2009, 12:36 PM
A movie clip's registration point is its 0,0 location in its own coordinate space. In its parent, this location is its x,y properties.

As for the top left, you can get its relative location by getting the bounds of the object in relation to itself.

var bounds:Rectangle = my_mc.getBounds(my_mc);
The top and left of that rectangle is the offset from 0,0 in my_mc's own coordinate space.

werehunt
08-20-2009, 04:26 PM
A movie clip's registration point is its 0,0 location in its own coordinate space. In its parent, this location is its x,y properties.

As for the top left, you can get its relative location by getting the bounds of the object in relation to itself.

var bounds:Rectangle = my_mc.getBounds(my_mc);
The top and left of that rectangle is the offset from 0,0 in my_mc's own coordinate space.

ok, so first two numbers in getBounds give me what i need.
funny question, but how do i get to these numbers? :D

var bounds:Rectangle = my_mc.getBounds(my_mc);
trace(bounds);
//(x=-50, y=-50, w=100, h=100)

rondog
08-20-2009, 04:31 PM
bounds.x, bounds.y


thats my guess

senocular
08-20-2009, 04:36 PM
Note the type, Rectangle
http://livedocs.adobe.com/flex/3/langref/flash/geom/Rectangle.html