Building Blocks if there’s one thing I know about me and my thoughts: given enough time I’m always wrong

21Mar/084

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?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>
  • 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
  • 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' ....
  • 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.
  • Hey Joel, glad you like it. And thanks for the mention :)

    -Marc (OH Author)
blog comments powered by Disqus