Put together a simple transform manager for a friend’s project. Supports dragging and single click scaling and rotating. Source provided after the jump.
[kml_flashembed movie=”http://ryantan.net/content/FTM/TestFTM.swf” height=”480″ width=”630″ /]
I call it FreeTransformManager because it is free, but maybe I should have called it Simple instead, because it lacks some advanced features such as disproportionate scaling, shearing or setting a custom pivot, which exists in Senocular’s awesome TransformTool class. However, I think it rather excels in being a simple and lite alternative to other components, as scaling and rotating is merged into a single action and the absence of other features makes the code smaller too. Suitable for cases where you do not require the advanced features and just need a simple way to allow users to move, scale and rotate objects.
That said, if you can fork out USD$300 then GreenSock’s full featured TransformManager would definitely be a better choice.
If you’ve tried it in your project and found it useful, do drop me a link. And if you found it really useful, do consider making a donation to fund v2.0! 😀
// Only need one instance per project
var fts:FreeTransformManager = new FreeTransformManager(false);
// Register any DisplayObject and you are done. handles are activated when user clicks on testObj
// Listen to ON_TRANSFORM event.
// Manually acticate the handlers on a DisplayObject
// Update the handlers after the DisplayObject is modified externally
// Whether to show tracking points and angle lines
// Hides handlers. But they will be visible again the next time the user clicks on a registered DisplayObject
Properties exposed by event:
targetObject:DisplayObject // The DisplayObject that is in focus.
x:Number // X position
y:Number // Y position
rotation:Number // Rotation in radians
rotationInDeg:Number // Rotation in degrees
scale:Number // Scale (1 = 100%)