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?
Put it inside a Canvas
container, with its clipContent
attribute set to false. Within the canvas, you can put your object wherever you like.
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)
.
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.