Put together a simple transform manager for a friend’s project. Supports dragging and single click scaling and rotating. Source provided after the jump.
Download: Source only | Source + Examples
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! ![]()
[donateplus]
Usage:
// 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
fts.registerSprite(box);
Other users:
// Listen to ON_TRANSFORM event.
fts.addEventListener(FreeTransformEvent.ON_TRANSFORM, onTransform);
// Manually acticate the handlers on a DisplayObject
activateSprite(sourceSprite:DisplayObject):void
// Update the handlers after the DisplayObject is modified externally
updateAfterChange():void
// Whether to show tracking points and angle lines
property showInterestingStuff
// Hides handlers. But they will be visible again the next time the user clicks on a registered DisplayObject
hideHandlers():void
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%)
Pingback: Top 10 Transform Tools built in AS3 for Flex and Flash