Archive for December 27th, 2007
Center Registration Point – Another Recipe for the Flex CookBook
by Dave on Dec.27, 2007, under Actual RIA info, Adobe Flex
Here’s a little recipe for scaling an image from a center registration point. Flash always allowed you to bounce the registration point wherever you wanted, but Flex expects it on the top left. If you want to resize an image from the center evenly, with a horizontal slider for example, you’ll like this one.
First the MXML. This layout is simple, it basically just has the small script with a function to accept a SilderEvent when the user changes the value of the horizontal slider. This function then uses the static functions (calcX() and calcY()) in the ImageResizer class to calculate the new math and tell your image how to resize properly from the center.