Flex component transformation with ObjectHandles

Rogue Development's ObjectHandles is a great component. It is simple to use and provides all of the functionality that I was looking for in a transformation modifier. Prior to implementing this, I was using the TransformTool from senocular.com's library. This is also a great utility, but it wants to scale my content, and that was a deal breaker in my current project. ObjectHandles does NOT resize the child components. There are use cases for both approaches, but ObjectHandles allows me to decide when to scale.

<?xml version="1.0" encoding="utf-8"?>
<ObjectHandles
	xmlns="com.roguedevelopment.objecthandles.*"
	xmlns:mx="http://www.adobe.com/2006/mxml"
	allowRotate="false"
	objectMovedEvent="objectUpdatedHandler( event )"
	width="{image.width}"
	height="{image.height}" >
<mx:Script>
	<![CDATA[
		import com.roguedevelopment.objecthandles.ObjectHandlesMouseCursors;
		public static const CHANGE:String = "imageBoxChanged";
 
		private function objectUpdatedHandler( event:Event ):void
		{
			dispatchEvent( new Event( CHANGE, true ) );
		}
	]]>
</mx:Script>
	<mx:Image id="image" source="@Embed(source='/assets/cower.png')" />
</ObjectHandles>

4 Responses to “Flex component transformation with ObjectHandles”


  1. 1 Marc Hughes

    Hey Joel, glad you like it. And thanks for the mention :)
    -Marc (OH Author)

  2. 2 Blaight

    Hey,I am so interested about that you had ever used the ‘TransformTool’ library in your Flex project. But there is little examples showing how to use it in flex, Would you please share some example about how to use ‘TransformTool’ in Flex? I have tried as such a way:

    but it failed at line
    canvas.addChild(defaultTool);
    Can you give any hints? Thanks.

  3. 3 Blaight

    sorry, some characters can not be displayed correctly above.
    I use TransformTool in a function in a mx:Script block in mxml file as :
    private var defaultTool : TransformTool;
    private function initTool() : void {
    defaultTool = new TransformTool();
    canvas.addChild(defaultTool);
    defaultTool.target = img;
    }

    mx:Canvas id=’canvas’ …
    mx:Image id=’img’ ….

  4. 4 Joel

    The problem is that the TransformTool is not a UIComponent, so you probably need to add it to a UIComponent as a child, and then add that to the stage. I will work up a proper example for you, but try this:

    var component:UIComponent = new UIComponent( );
    component.addChild( defaultTool );
    this.addChild( component );

    It has been a while, let me get it working and I will post it.

    Cheers,

    Joel

Leave a Reply