Sometimes our programs have visual objects that need to be rotated. The default registration point in Flex is the top left corner, but that’s not always ideal. In Flash, we have the freedom to change that registration point — not in Flex.
We have to work around this limitation in Flex and I have seen a few different approaches. There are some blog posts out there that suggest using the Rotate effect, this seems messy to me. If you want to rotate around any point using a MatrixTransformer: Joel Connett has a great post on it here. I quite like that method, but I think I’ve found a more simple solution for center rotation.
Here’s a sample you can play with:
Click Here for Source Code
Try clicking the "show canvas" button, you'll see a white box that surrounds the bottom right quadrant of the spiral circle. It is only that quarter of the circle which is actually in the canvas. I have placed the center of the circle at the top left corner of the canvas. The canvas will (by default) crop content that exceeds it's boundaries; however, there is a property on the canvas called "clipContent". Set that to false and voila.
I know this is really simple solution, but it wasn't obvious to me until recently. Leave a comment to let me know if this helped to you.
This method works with Flex 2 and Flex 3.
Great idea – just what I was looking for 🙂
(Why didn’t I think of this myself??)
Thanks 🙂
This is great and was very helpful, thanks!
good idea, thanks!
Good Idea.
Thanks,
-Mahesh.
The source code isn’t avalible….
This is pretty cool.
Another option, especially if you’re doing this programmatically, is to add the item to a parent UIComponent, and offset it within the UIComponent.
– Derrick
NOOO! The source is gone! Why didn’t you give us a little hint in your body?!?!?!? This is exactly what I’m looking for I think but I can’t tell. maybe I can decompile your swf?!
Great! Really clever solution.
FYI – The source has been fixed.
In flex 4.0 works fine too;) THANKS!
Really Simple and great idea. thanks
This is so KISS (Keep it simple stupid). I love it! Works fine in Flex4.6. Thanks.