Building Blocks [without unit tests] you’re not refactoring; you’re just changing shit. -Hamlet D’Arcy

20Apr/0813

Using the Senocular AS3 TransformTool in Flex

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.

Like most pure AS3 display classes, the TransformTool needs to be added to a UIComponent wrapper to function properly in Flex.

Source.

  • greek
    Hello,

    Great tool, but how to implement a delete function?
  • mukesh
    Hi, a great tool, but do u have any idea how to dispatch key event on tool , like delete key press to remove the tool .
  • I don't think the transform tool from Senocular does resize the controls containing the text elements like textarea. It actually scales the target. I have created my own custom transform tool which works wonderfully also with rotating cursors.
  • Joel
    My guess is that you need to use embedded fonts.
  • Neo
    Nice example,but the transformToll can not transform the TexArea,any idea?
  • kanu kukreja
    I want to add delete control on top right, i tried alot and added 2 neew classes as well "TransformToolDeleteControl.as" & "TransformToolDeleteCursor.as", but that control is not getting visible anyhow.
    And one more thing if i move rotation control in to center then it stops working.
    Can anybody please share their ideas with me.
  • @rui

    That was ultimately why I stopped using this tool and went with ObjectHandles instead.
  • rui
    I don like it, it just implements matrix, in some cases this is great, but if I'm applying to an container, I don want scale the container (just width/height), imagine that I have a frame border on that picture, then the border will stretch too.. i had senocular full implemented on adigitalbook.com, then i had to remove :(
  • I think there is one line missing in the function scaleTopRightInteraction. Add below
    _toolMatrix.ty += oldBounds.subtract(boundsBottomLeft).y;
    the line:
    _toolMatrix.tx += oldBounds.subtract(boundsBottomLeft).x;

    Otherwise, scaling of a rotated target does not work properly.

    There is also the issue with resizing the browser. The controls and the target move apart as soon as the browser window is resized.
  • ynk
    when u rotate then scale, the scale doesnt follow properly the cursor because of the difference between mouse coordinates which are always with a 'virtual' rotation=0 and the angle of the object.

    i had the same bug while doing my class. I used this :

    var rotationRad:Number = rotation * Math.PI / 180;
    var px:Number = XY.x * Math.cos(rotationRad) - XY.y * Math.sin(rotationRad);
    var py:Number = XY.x * Math.sin(rotationRad) + XY.y * Math.cos(rotationRad);

    hope it'll work
  • Joel
    I add the TransformTool to the top level container.
  • Blaight
    You are so nice. The source code is availiable now. Thank you very much.

    But I have a little problem. Do I have to add the TransformTool to the top level container such as Application in your example? Based on your example, if I use
    hbox.addChild( component);
    then something strange happends. It seems that the TransformTool is 'under' the image and can not response to moving action the rotation point can not be seen yet.
  • Blaight
    It is so great. Thanks a lot.
    Expects example with detailed source code.
blog comments powered by Disqus