views:

904

answers:

3

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?

A: 

Put it inside a Canvas container, with its clipContent attribute set to false. Within the canvas, you can put your object wherever you like.

David Hanak
Canvas adds some pretty big overhead if you'll be doing this for many display objects. Members of Adobe's Flex team recommend keeping the number of containers in a Flex application to a minimum.
joshtynjala
+1  A: 

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).

Troy Gilbert
+1  A: 

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.

PiPeep