Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex: Setting the resgistration point on a display object

What is the best way to change/set a registration point on a Flex 3 display object? I know this isn't really built in to easily change, but does anyone have any suggestions on how I could extend UIComponent to achieve this?

like image 257
bkildow Avatar asked Mar 05 '09 14:03

bkildow


2 Answers

For some reason, the Flash Player API doesn't expose the registration point of DisplayObjects (and the Flash IDE makes them a pain to modify once an object is created). The best solution, as David pointed out, is to add your component as a child of another component (UIComponent would be fine). So, for example, if I had a Button and I wanted its registration point at its center, I'd add it as a child of a UIComponent (not Canvas) and offset the child by setting its position to (-button.width/2, -button.height/2).

like image 194
Troy Gilbert Avatar answered Oct 23 '22 19:10

Troy Gilbert


Put your DisplayObject inside a sprite and set the DisplayObject's x & y positions to the negitive of your target registration point. Apply all transforms to the Sprite container.

like image 24
bgw Avatar answered Oct 23 '22 17:10

bgw