senocular.com TransformTool modification

Recently I used the great senocular Transform Tool for a Flex2 project.
We just needed to made a little modification to the way the scale transformation worked. Something like the Photoshop’s Transform tool, where the registration point only affects rotation, while all the scale controls are independent from the registration point.
For this reason I modified a bit the TransformTool code to allow this feature to be set on/off (I called this scaleWithRegistration)

Hold down SHIFT key while rotating or scaling to constrain transformation
Double click to complete transformation.

[kml_flashembed publishmethod=”static” fversion=”10.0.22″ movie=”http://blog.sephiroth.it/wp-content/uploads/2007/07/test_transformation.swf” width=”400″ height=”300″ targetclass=”flashmovie” bgColor=”#cccccc”]

Get Adobe Flash player

[/kml_flashembed]

This is the code used in the mxml Application file:

< ?xml version="1.0" encoding="utf-8"?>



< ![CDATA[ import com.senocular.display.TransformTool; [Bindable] private var tool:TransformTool; private function init():void { } private function onImageComplete(event:Event):void { var timer:Timer = new Timer(1000,1); timer.addEventListener(TimerEvent.TIMER, function(evt:TimerEvent):void { createTool(null); }); timer.start(); image.addEventListener(MouseEvent.CLICK, createTool); } private function onDoubleClick(event:MouseEvent):void { removeChild(tool); tool = null; } private function createTool(event:MouseEvent):void { if(!tool) { tool = new TransformTool(); tool.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick); tool.target = image; tool.scaleWithRegistration = scale_registration.selected; addChild(tool); } } ]]>



[attachments docid=1018 force_saveas=”1″ logged_users=”0″]

Share with...