Packagecom.greensock.transform
Classpublic class FlexTransformManager
InheritanceFlexTransformManager Inheritance mx.containers.Canvas

FlexTransformManager works with TransformManager and makes it easy to add interactive scaling/rotating/moving of DisplayObjects to your Flex application. It uses an intuitive interface that's similar to most modern drawing applications. When the user clicks on a managed DisplayObject, a selection box will be drawn around it along with 8 handles for scaling/rotating. When the mouse is placed just outside of any of the scaling handles, the cursor will change to indicate that they're in rotation mode. Just like most other applications, the user can hold down the SHIFT key to select multiple items, to constrain scaling proportions, or to limit the rotation to 45 degree increments. All the work is done by the TransformManager instance which is compatible with Flash, but FlexTransformManager is basically a wrapper that makes it compatible with Flex.

FEATURES INCLUDE:

NOTES / LIMITATIONS:

EXAMPLES:

To make two Images (myImage1 and myImage2) transformable using the default settings:

     <?xml version="1.0" encoding="utf-8"?>
     <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:transform="com.greensock.transform.*">
         <transform:FlexTransformManager id="myManager" width="500" height="500"> 
             <mx:Image source="../libs/image1.png" id="myImage1" autoLoad="true" x="100" y="100" /> 
             <mx:Image source="../libs/image2.png" id="myImage2" autoLoad="true" x="0" y="300" /> 
         </transform:FlexTransformManager>
     </mx:Application>

To make the two Images transformable, constrain their scaling to be proportional (even if the user is not holding down the shift key), call the onScale function everytime one of the objects is scaled, lock the rotation value of each Image (preventing rotation), and allow the delete key to appear to delete the selected Image from the stage:

     <?xml version="1.0" encoding="utf-8"?>
     <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:transform="com.greensock.transform.*" creationComplete="init()">
         <mx:Script>
             <![CDATA[
                 import com.greensock.events.TransformEvent;
                 private function init():void {
                     myManager.addEventListener(TransformEvent.SCALE, onScale, false, 0, true);
                 }
                 private function onScale($e:TransformEvent):void {
                     trace("Scaled " + $e.items.length + " items");
                 }
            ]]>
         </mx:Script>
         <transform:FlexTransformManager id="myManager" width="500" height="500" allowDelete="true" constrainScale="true" lockRotation="true">
             <mx:Image source="../libs/image1.png" id="image1" autoLoad="true" x="50" y="50" />
             <mx:Image source="../libs/image1.png" id="image2" autoLoad="true" x="100" y="200" />
         </transform:FlexTransformManager>
     </mx:Application>

Copyright 2008-2012, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/eula.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.



Public Properties
 PropertyDefined By
  allowDelete : Boolean
If true, when the user presses the DELETE (or BACKSPACE) key, the selected item(s) will be deleted (except items with hasSelectableText set to true) [default: false]
FlexTransformManager
  allowMultiSelect : Boolean
If true, multiple items can be selected (by holding down the SHIFT or CONTROL keys and clicking) [default: true]
FlexTransformManager
  arrowKeysMove : Boolean
If true, the arrow keys on the keyboard will move the selected items when pressed [default: false]
FlexTransformManager
  autoDeselect : Boolean
When the user clicks anywhere OTHER than on one of the TransformItems, all are deselected [default: true]
FlexTransformManager
  bounds : Rectangle
A Rectangle defining the boundaries for movement/scaling/rotation.
FlexTransformManager
  constrainScale : Boolean
To constrain items to only scaling proportionally, set this to true [default: false]
FlexTransformManager
  enabled : Boolean
[override] Enable or disable the entire FlexTransformManager.
FlexTransformManager
  forceSelectionToFront : Boolean
When true, new selections are forced to the front of the display list of the container DisplayObjectContainer [default: true]
FlexTransformManager
  handleFillColor : uint
Controls the fill color of the handle [default: 0xFFFFFF]
FlexTransformManager
  handleSize : Number
Controls the handle size (in pixels) [default: 8]
FlexTransformManager
  height : Number
[override] [write-only] height
FlexTransformManager
  hideCenterHandle : Boolean
To hide the center scale handle, set this to true [default: false
FlexTransformManager
  ignoredObjects : Array
Sometimes you want FlexTransformManager to ignore clicks on certain DisplayObjects, like buttons, color pickers, etc.
FlexTransformManager
  items : Array
[read-only] All of the TransformItem instances that are managed by this FlexTransformManager (regardless of whether or not they're selected)
FlexTransformManager
  lineColor : uint
Controls the line color of the selection box and handles [default: 0x3399FF]
FlexTransformManager
  lineThickness : Number
Controls the thickness of the selection box and handle lines [default: 1]
FlexTransformManager
  lockPosition : Boolean
Prevents moving [default: false]
FlexTransformManager
  lockRotation : Boolean
Prevents rotating [default: false]
FlexTransformManager
  lockScale : Boolean
Prevents scaling [default: false]
FlexTransformManager
  manager : TransformManager
[read-only] The TransformManager instance associated with the FlexTransformManager
FlexTransformManager
  paddingForRotation : Number
Determines the amount of space outside each of the four corner scale handles that will trigger rotation mode [default: 12]
FlexTransformManager
  scaleFromCenter : Boolean
If true, scaling occurs from the center of the selection instead of the corners.
FlexTransformManager
  selectedItems : Array
The currently selected TransformItems (for the associated DisplayObjects, use selectedTargetObjects)
FlexTransformManager
  selectedTargetObjects : Array
The currently selected targetObjects (DisplayObjects).
FlexTransformManager
  selectionRotation : Number
The rotation of the overall selection box
FlexTransformManager
  selectionScaleX : Number
The scaleX of the overall selection box
FlexTransformManager
  selectionScaleY : Number
The scaleY of the overall selection box
FlexTransformManager
  selectionX : Number
The x-coordinte of the overall selection box (same as the origin)
FlexTransformManager
  selectionY : Number
The y-coordinte of the overall selection box (same as the origin)
FlexTransformManager
  targetObjects : Array
[read-only] All of the targetObjects (DisplayObjects) that are managed by this FlexTransformManager (regardless of whether or not they're selected)
FlexTransformManager
  transformManager : TransformManager
[read-only] The TransformManager instances associated with this FlexTransformManager
FlexTransformManager
  width : Number
[override] [write-only] width
FlexTransformManager
Public Methods
 MethodDefined By
  
FlexTransformManager($vars:Object = null)
Constructor
FlexTransformManager
  
addChild($child:DisplayObject):DisplayObject
[override] Adds a child and performs an addItem() so that the new child is managed.
FlexTransformManager
  
addChildAt($child:DisplayObject, $index:int):DisplayObject
[override] Adds a child at a particular index and then performs an addItem() to ensure the item is managed
FlexTransformManager
  
addEventListener($type:String, $listener:Function, $useCapture:Boolean = false, $priority:int = 0, $useWeakReference:Boolean = false):void
[override] Allows listening for the following events: TransformEvent.MOVE TransformEvent.SCALE TransformEvent.ROTATE TransformEvent.DELETE TransformEvent.SELECTION_CHANGE TransformEvent.CLICK_OFF TransformEvent.SEIZE_CURSOR TransformEvent.RELEASE_CURSOR TransformEvent.DEPTH_CHANGE TransformEvent.DESTROY TransformEvent.START_INTERACTIVE_MOVE TransformEvent.START_INTERACTIVE_SCALE TransformEvent.START_INTERACTIVE_ROTATE TransformEvent.FINISH_INTERACTIVE_MOVE TransformEvent.FINISH_INTERACTIVE_SCALE TransformEvent.FINISH_INTERACTIVE_ROTATE TransformEvent.DOUBLE_CLICK
FlexTransformManager
  
addIgnoredObject($object:DisplayObject):void
Allows you to have FlexTransformManager ignore clicks on a particular DisplayObject (handy for buttons, color pickers, etc.).
FlexTransformManager
  
addItem($targetObject:DisplayObject, $scaleMode:String = scaleNormal, $hasSelectableText:Boolean = false):TransformItem
In order for a DisplayObject to be managed by FlexTransformManger, it must first be added via addItem().
FlexTransformManager
  
addItems($targetObjects:Array, $scaleMode:String = scaleNormal, $hasSelectableText:Boolean = false):Array
Same as addItem() but accepts an Array containing multiple DisplayObjects.
FlexTransformManager
  
addSelectionBoxElement(element:DisplayObject, alignment:String = topRight, xOffset:Number = 0, yOffset:Number = 0, underHandles:Boolean = false):void
Attaches a DisplayObject of your choice to the selection box itself so that it appears to move with the selection box as the user interacts with it.
FlexTransformManager
  
applyFullXML(xml:XML, defaultParent:DisplayObjectContainer, placeholderColor:uint = 0xCCCCCC):Array
Applies XML generated by exportFullXML() to the TransformManager instance including all settings and each item's scale/rotation/position.
FlexTransformManager
  
applyItemXML(xml:XML, defaultParent:DisplayObjectContainer = null, placeholderColor:uint = 0xCCCCCC):DisplayObject
Applies XML generated by exportItemXML() to the TransformManager instance including all transform data like scale/rotation/position.
FlexTransformManager
  
applySettingsXML(xml:XML):void
Applies settings XML generated by exportSettingsXML() to the TransformManager instance.
FlexTransformManager
  
deleteSelection($e:Event = null):void
Deletes all selected items.
FlexTransformManager
  
Deselects all items
FlexTransformManager
  
deselectItem($item:*):void
Deselects a TransformItem or DisplayObject.
FlexTransformManager
  
destroy():void
Destroys the FlexTransformManager instance, removing all items and preparing it for garbage collection
FlexTransformManager
  
A common request is to capture the current state of each item's scale/rotation/position and the TransformManager's settings in an easy-to-store format so that the data can be reloaded and applied later; exportFullXML() returns an XML object containing exactly that.
FlexTransformManager
  
exportItemXML(targetObject:DisplayObject):XML
Exports transform data (scale/rotation/position) of a particular DisplayObject in XML format so that it can be saved to a database or elsewhere easily and then reapplied later.
FlexTransformManager
  
Exports the TransformManager's settings in XML format so that it can be saved to a database or elsewhere easily and then reapplied later.
FlexTransformManager
  
getItem($targetObject:DisplayObject):TransformItem
Gets the TransformItem associated with a particular DisplayObject (if any).
FlexTransformManager
  
getSelectionBounds(targetCoordinateSpace:DisplayObject = null):Rectangle
Gets the bounding Rectangle of the current selection (not including handles)
FlexTransformManager
  
getSelectionBoundsWithHandles(targetCoordinateSpace:DisplayObject = null):Rectangle
Gets the bounding Rectangle of the current selection (including handles)
FlexTransformManager
  
Gets the center point of the current selection
FlexTransformManager
  
Gets the height of the selection as if it were not rotated.
FlexTransformManager
  
Gets the width of the selection as if it were not rotated.
FlexTransformManager
  
isSelected($item:*):Boolean
Determines whether or not a particular DisplayObject or TranformItem is currently selected.
FlexTransformManager
  
moveSelection($x:Number, $y:Number, $dispatchEvents:Boolean = true):void
Moves the selected items by a certain number of pixels on the x axis and y axis
FlexTransformManager
  
Moves the selection down one level.
FlexTransformManager
  
Moves the selection up one level.
FlexTransformManager
  
[override] Removes all children
FlexTransformManager
  
removeChild($child:DisplayObject):DisplayObject
[override] Removes a child DisplayObject
FlexTransformManager
  
removeChildAt($index:int):DisplayObject
[override] Removes a child from a particular index number in the display list
FlexTransformManager
  
removeEventListener($type:String, $listener:Function, $useCapture:Boolean = false):void
[override] Removes an Event listener
FlexTransformManager
  
removeIgnoredObject($object:DisplayObject):void
Removes an ignored DisplayObject so that its clicks are no longer ignored.
FlexTransformManager
  
removeItem($item:*):void
Removes an item.
FlexTransformManager
  
removeSelectionBoxElement(element:DisplayObject):void
Releases a DisplayObject that was attached using addSelectionBoxElement().
FlexTransformManager
  
rotateSelection($angle:Number, $dispatchEvents:Boolean = true):void
Rotates the selected items by a particular angle (in Radians).
FlexTransformManager
  
scaleSelection($sx:Number, $sy:Number, $dispatchEvents:Boolean = true):void
Scales the selected items along the x- and y-axis using multipliers.
FlexTransformManager
  
selectItem($item:*, $addToSelection:Boolean = false):void
Selects a particular TransformItem or DisplayObject (you must have already added the DisplayObject to FlexTransformManager in order for it to be selectable - use addItem() for that)
FlexTransformManager
  
selectItems($items:Array, $addToSelection:Boolean = false):void
Selects an Array of TransformItems and/or DisplayObjects.
FlexTransformManager
  
setActualSize(w:Number, h:Number):void
[override]
FlexTransformManager
  
updateSelection($centerOrigin:Boolean = true):void
Refreshes the selection box/handles.
FlexTransformManager
Events
 Event Summary Defined By
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
  FlexTransformManager
Public Constants
 ConstantDefined By
  VERSION : Number = 1.9662
[static]
FlexTransformManager
Property Detail
allowDeleteproperty
allowDelete:Boolean

If true, when the user presses the DELETE (or BACKSPACE) key, the selected item(s) will be deleted (except items with hasSelectableText set to true) [default: false]


Implementation
    public function get allowDelete():Boolean
    public function set allowDelete(value:Boolean):void
allowMultiSelectproperty 
allowMultiSelect:Boolean

If true, multiple items can be selected (by holding down the SHIFT or CONTROL keys and clicking) [default: true]


Implementation
    public function get allowMultiSelect():Boolean
    public function set allowMultiSelect(value:Boolean):void
arrowKeysMoveproperty 
arrowKeysMove:Boolean

If true, the arrow keys on the keyboard will move the selected items when pressed [default: false]


Implementation
    public function get arrowKeysMove():Boolean
    public function set arrowKeysMove(value:Boolean):void
autoDeselectproperty 
autoDeselect:Boolean

When the user clicks anywhere OTHER than on one of the TransformItems, all are deselected [default: true]


Implementation
    public function get autoDeselect():Boolean
    public function set autoDeselect(value:Boolean):void
boundsproperty 
bounds:Rectangle

A Rectangle defining the boundaries for movement/scaling/rotation. [default:null]


Implementation
    public function get bounds():Rectangle
    public function set bounds(value:Rectangle):void
constrainScaleproperty 
constrainScale:Boolean

To constrain items to only scaling proportionally, set this to true [default: false]


Implementation
    public function get constrainScale():Boolean
    public function set constrainScale(value:Boolean):void
enabledproperty 
enabled:Boolean[override]

Enable or disable the entire FlexTransformManager.


Implementation
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void
forceSelectionToFrontproperty 
forceSelectionToFront:Boolean

When true, new selections are forced to the front of the display list of the container DisplayObjectContainer [default: true]


Implementation
    public function get forceSelectionToFront():Boolean
    public function set forceSelectionToFront(value:Boolean):void
handleFillColorproperty 
handleFillColor:uint

Controls the fill color of the handle [default: 0xFFFFFF]


Implementation
    public function get handleFillColor():uint
    public function set handleFillColor(value:uint):void
handleSizeproperty 
handleSize:Number

Controls the handle size (in pixels) [default: 8]


Implementation
    public function get handleSize():Number
    public function set handleSize(value:Number):void
heightproperty 
height:Number  [write-only] [override]

height


Implementation
    public function set height(value:Number):void
hideCenterHandleproperty 
hideCenterHandle:Boolean

To hide the center scale handle, set this to true [default: false


Implementation
    public function get hideCenterHandle():Boolean
    public function set hideCenterHandle(value:Boolean):void
ignoredObjectsproperty 
ignoredObjects:Array

Sometimes you want FlexTransformManager to ignore clicks on certain DisplayObjects, like buttons, color pickers, etc. Those items should populate the ignoreObjects Array. The DisplayObject CANNOT be a child of a targetObject.


Implementation
    public function get ignoredObjects():Array
    public function set ignoredObjects(value:Array):void
itemsproperty 
items:Array  [read-only]

All of the TransformItem instances that are managed by this FlexTransformManager (regardless of whether or not they're selected)


Implementation
    public function get items():Array
lineColorproperty 
lineColor:uint

Controls the line color of the selection box and handles [default: 0x3399FF]


Implementation
    public function get lineColor():uint
    public function set lineColor(value:uint):void
lineThicknessproperty 
lineThickness:Number

Controls the thickness of the selection box and handle lines [default: 1]


Implementation
    public function get lineThickness():Number
    public function set lineThickness(value:Number):void
lockPositionproperty 
lockPosition:Boolean

Prevents moving [default: false]


Implementation
    public function get lockPosition():Boolean
    public function set lockPosition(value:Boolean):void
lockRotationproperty 
lockRotation:Boolean

Prevents rotating [default: false]


Implementation
    public function get lockRotation():Boolean
    public function set lockRotation(value:Boolean):void
lockScaleproperty 
lockScale:Boolean

Prevents scaling [default: false]


Implementation
    public function get lockScale():Boolean
    public function set lockScale(value:Boolean):void
managerproperty 
manager:TransformManager  [read-only]

The TransformManager instance associated with the FlexTransformManager


Implementation
    public function get manager():TransformManager
paddingForRotationproperty 
paddingForRotation:Number

Determines the amount of space outside each of the four corner scale handles that will trigger rotation mode [default: 12]


Implementation
    public function get paddingForRotation():Number
    public function set paddingForRotation(value:Number):void
scaleFromCenterproperty 
scaleFromCenter:Boolean

If true, scaling occurs from the center of the selection instead of the corners. [default: false]


Implementation
    public function get scaleFromCenter():Boolean
    public function set scaleFromCenter(value:Boolean):void
selectedItemsproperty 
selectedItems:Array

The currently selected TransformItems (for the associated DisplayObjects, use selectedTargetObjects)


Implementation
    public function get selectedItems():Array
    public function set selectedItems(value:Array):void
selectedTargetObjectsproperty 
selectedTargetObjects:Array

The currently selected targetObjects (DisplayObjects). For the associated TransformItems, use selectedItems.


Implementation
    public function get selectedTargetObjects():Array
    public function set selectedTargetObjects(value:Array):void
selectionRotationproperty 
selectionRotation:Number

The rotation of the overall selection box


Implementation
    public function get selectionRotation():Number
    public function set selectionRotation(value:Number):void
selectionScaleXproperty 
selectionScaleX:Number

The scaleX of the overall selection box


Implementation
    public function get selectionScaleX():Number
    public function set selectionScaleX(value:Number):void
selectionScaleYproperty 
selectionScaleY:Number

The scaleY of the overall selection box


Implementation
    public function get selectionScaleY():Number
    public function set selectionScaleY(value:Number):void
selectionXproperty 
selectionX:Number

The x-coordinte of the overall selection box (same as the origin)


Implementation
    public function get selectionX():Number
    public function set selectionX(value:Number):void
selectionYproperty 
selectionY:Number

The y-coordinte of the overall selection box (same as the origin)


Implementation
    public function get selectionY():Number
    public function set selectionY(value:Number):void
targetObjectsproperty 
targetObjects:Array  [read-only]

All of the targetObjects (DisplayObjects) that are managed by this FlexTransformManager (regardless of whether or not they're selected)


Implementation
    public function get targetObjects():Array
transformManagerproperty 
transformManager:TransformManager  [read-only]

The TransformManager instances associated with this FlexTransformManager


Implementation
    public function get transformManager():TransformManager
widthproperty 
width:Number  [write-only] [override]

width


Implementation
    public function set width(value:Number):void
Constructor Detail
FlexTransformManager()Constructor
public function FlexTransformManager($vars:Object = null)

Constructor

Parameters
$vars:Object (default = null) — An object specifying any properties that should be set upon instantiation, like {scaleFromCenter:true, lockRotation:true, bounds:new Rectangle(0, 0, 500, 300)}.
Method Detail
addChild()method
override public function addChild($child:DisplayObject):DisplayObject

Adds a child and performs an addItem() so that the new child is managed.

Parameters

$child:DisplayObject — The child DisplayObject

Returns
DisplayObject — DisplayObject
addChildAt()method 
override public function addChildAt($child:DisplayObject, $index:int):DisplayObject

Adds a child at a particular index and then performs an addItem() to ensure the item is managed

Parameters

$child:DisplayObject — The child DisplayObject to add
 
$index:int — The index number in the display list at which to add the child

Returns
DisplayObject — DisplayObject
addEventListener()method 
override public function addEventListener($type:String, $listener:Function, $useCapture:Boolean = false, $priority:int = 0, $useWeakReference:Boolean = false):void

Allows listening for the following events:

Parameters

$type:String — Event type
 
$listener:Function — Listener function
 
$useCapture:Boolean (default = false) — Use capture phase
 
$priority:int (default = 0) — Priority
 
$useWeakReference:Boolean (default = false) — Use weak reference

addIgnoredObject()method 
public function addIgnoredObject($object:DisplayObject):void

Allows you to have FlexTransformManager ignore clicks on a particular DisplayObject (handy for buttons, color pickers, etc.). The DisplayObject CANNOT be a child of a targetObject

Parameters

$object:DisplayObject — DisplayObject that should be ignored

addItem()method 
public function addItem($targetObject:DisplayObject, $scaleMode:String = scaleNormal, $hasSelectableText:Boolean = false):TransformItem

In order for a DisplayObject to be managed by FlexTransformManger, it must first be added via addItem(). When the DisplayObject is added, a TransformItem instance is automatically created and associated with the DisplayObject. If you need to set item-specific settings like minScaleX, maxScaleX, etc., you would set those via the TransformItem instance. addItem() returns a TransformItem instance, but you can retrieve it anytime with the getItem() method (just pass it your DisplayObject, like var myItem:TransformItem = myManager.getItem(myDisplayObject).

Parameters

$targetObject:DisplayObject — The DisplayObject to be managed
 
$scaleMode:String (default = scaleNormal) — Either TransformManager.SCALE_NORMAL for normal scaleX/scaleY scaling or TransformManager.SCALE_WIDTH_AND_HEIGHT if you prefer that FlexTransformManager alters the width/height properties instead.
 
$hasSelectableText:Boolean (default = false) — If true, this prevents dragging of the object unless clicking on the edges/border or center handle, and allows the DELETE key to be pressed without deleting the object itself. It will also force the scaleMode to TransformManager.SCALE_WIDTH_AND_HEIGHT.

Returns
TransformItem — TransformItem instance
addItems()method 
public function addItems($targetObjects:Array, $scaleMode:String = scaleNormal, $hasSelectableText:Boolean = false):Array

Same as addItem() but accepts an Array containing multiple DisplayObjects.

Parameters

$targetObjects:Array — An Array of DisplayObject to be managed
 
$scaleMode:String (default = scaleNormal) — Either TransformManager.SCALE_NORMAL for normal scaleX/scaleY scaling or TransformManager.SCALE_WIDTH_AND_HEIGHT if you prefer that FlexTransformManager alters the width/height properties instead.
 
$hasSelectableText:Boolean (default = false) — If true, this prevents dragging of the objects unless clicking on the edges/border or center handle, and allows the DELETE key to be pressed without deleting the object itself. It will also force the scaleMode to TransformManager.SCALE_WIDTH_AND_HEIGHT.

Returns
Array — An Array of corresponding TransformItems that are created
addSelectionBoxElement()method 
public function addSelectionBoxElement(element:DisplayObject, alignment:String = topRight, xOffset:Number = 0, yOffset:Number = 0, underHandles:Boolean = false):void

Attaches a DisplayObject of your choice to the selection box itself so that it appears to move with the selection box as the user interacts with it. This is a great way to add your own interface elements, like a "delete" icon/button. You can set the alignment to any of the selection handles: "topLeft", "top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", or "left" and you can also define offset values so that the object doesn't sit right on top of the handle (or just alter the registration point of your DisplayObject to accomplish something similar). For example, if I want to attach a Sprite named "deleteButton" to the selection box in the upper right corner and offset it by 40 pixels on the x-axis and 0 pixels on the y-axis, I'd do:

myManager.addSelectionBoxElement(deleteButton, "topRight", 40, 0);

Parameters

element:DisplayObject — The DisplayObject to attach to the selection (it will be moved into the selection Sprite that TransformManager uses)
 
alignment:String (default = topRight) — "topLeft", "top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", or "left"
 
xOffset:Number (default = 0) — The number of pixels to offset the element on the x-axis (when the selection box isn't rotated)
 
yOffset:Number (default = 0) — The number of pixels to offset the element on the y-axis (when the selection box isn't rotated)
 
underHandles:Boolean (default = false) — By default, the element will be placed above the scale/rotation handles, but if you prefer that the element is positioned under the handles, set underHandles to true

See also

applyFullXML()method 
public function applyFullXML(xml:XML, defaultParent:DisplayObjectContainer, placeholderColor:uint = 0xCCCCCC):Array

Applies XML generated by exportFullXML() to the TransformManager instance including all settings and each item's scale/rotation/position. This does not load any external images/assets - you must do that separately. Typically it's best to fully load the assets first and add them to the display list before calling applyFullXML(). When applyFullXML() is called, it attempts to find the targetObjects in the display list based on their names, but for each one that cannot be found, a new Sprite will be created and added as a placeholder, filled with the placeholderColor and named identically. An array of those placeholders (if any) is returned by applyFullXML() which makes it easy to loop through and load your images/assets directly into those placeholder Sprites. Feel free to add visual preloaders, alter the look of the Sprites, etc.

Parameters

xml:XML — An XML object containing data about the settings and each item's position/scale/rotation. This XML is typically created using exportFullXML().
 
defaultParent:DisplayObjectContainer — If no items have been added to the TransformManager yet, it won't know which DisplayObjectContainer to look in for targetObjects, so it is important to explicitly tell TransformManager what default parent to use.
 
placeholderColor:uint (default = 0xCCCCCC) — If an item's targetObject cannot be found in the display list (based on its name), it will create a new Sprite and fill it with this color, using it as a placeholder.

Returns
Array — An array of placeholders that were created for missing targetObjects (if any). You can loop through these and load your assets accordingly. Keep in mind that the placeholders will have the same name as was defined in the XML (from the original targetObject).

See also

applyItemXML()method 
public function applyItemXML(xml:XML, defaultParent:DisplayObjectContainer = null, placeholderColor:uint = 0xCCCCCC):DisplayObject

Applies XML generated by exportItemXML() to the TransformManager instance including all transform data like scale/rotation/position. This does not load any external images/assets - you must do that separately. Typically it's best to fully load the asset first and add them to the display list before calling applyItemXML(). When applyItemXML() is called, it attempts to find the targetObject in the display list based on its name, but if it cannot be found, a new Sprite will be created and added as a placeholder, filled with the placeholderColor and named identically. To load all of the settings and every item's transform data, use applyFullXML() instead.

Parameters

xml:XML — An XML object containing data about the item's position/scale/rotation. This XML is typically created using exportItemXML().
 
defaultParent:DisplayObjectContainer (default = null) — If no items have been added to the TransformManager yet, it won't know which DisplayObjectContainer to look in for targetObject, so it is important to explicitly tell TransformManager what default parent to use.
 
placeholderColor:uint (default = 0xCCCCCC) — If the targetObject cannot be found in the display list (based on its name), it will create a new Sprite and fill it with this color, using it as a placeholder.

Returns
DisplayObject — The DisplayObject associated with the item (a placeholder Sprite if the targeObject wasn't found in the display list).

See also

applySettingsXML()method 
public function applySettingsXML(xml:XML):void

Applies settings XML generated by exportSettingsXML() to the TransformManager instance. This determines things like allowDelete, autoDeselect, lockScale, lockPosition, etc.

Parameters

xml:XML — An XML object containing settings data about the TransformManager (typically exported by exportSettingsXML()).

See also

deleteSelection()method 
public function deleteSelection($e:Event = null):void

Deletes all selected items.

Parameters

$e:Event (default = null) — Accepts an optional Event in case you want to use this as an event handler

deselectAll()method 
public function deselectAll():void

Deselects all items

deselectItem()method 
public function deselectItem($item:*):void

Deselects a TransformItem or DisplayObject.

Parameters

$item:* — The TransformItem or DisplayObject that should be deselected

destroy()method 
public function destroy():void

Destroys the FlexTransformManager instance, removing all items and preparing it for garbage collection

exportFullXML()method 
public function exportFullXML():XML

A common request is to capture the current state of each item's scale/rotation/position and the TransformManager's settings in an easy-to-store format so that the data can be reloaded and applied later; exportFullXML() returns an XML object containing exactly that. The TransformManager's settings and each item's transform data is stored in the following format:

Returns
XML — An XML representation of the current state of the TransformManager instance and all of the items it is managing.

See also


Example
<transformManageramp;gt;
  <settings allowDelete="1" allowMultiSelect="1" autoDeselect="1" constrainScale="0" lockScale="1" scaleFromCenter="0" lockRotation="0" lockPosition="0" arrowKeysMove="0" forceSelectionToFront="1" lineColor="3381759" handleColor="16777215" handleSize="8" paddingForRotation="12" hideCenterHandle="0"/>
  <items>
    <item name="mc1" level="1" a="0.9999847412109375" b="0" c="0" d="0.9999847412109375" tx="79.2" ty="150.5" xOffset="-23.4" yOffset="-34.35" rawWidth="128.6" rawHeight="110.69999999999999" scaleMode="scaleNormal" hasSelectableText="0" minScaleX="-Infinity" maxScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"/>
    <item name="mc2" level="18" a="0.7987213134765625" b="0.2907257080078125" c="-0.2907257080078125" d="0.7987213134765625" tx="222.5" ty="92.25" xOffset="0" yOffset="0" rawWidth="287.85" rawHeight="215.8" scaleMode="scaleNormal" hasSelectableText="0" minScaleX="-Infinity" maxScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"/>
    <item name="text_ti" level="4" a="1" b="0" c="0" d="1" tx="32" ty="303.95" xOffset="-2" yOffset="-2" rawWidth="188" rawHeight="37.2" scaleMode="scaleWidthAndHeight" hasSelectableText="1" minScaleX="-Infinity" maxScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"/>
  </items>
</transformManager>

You can use applyFullXML() to reapply the exported XML.

exportItemXML()method 
public function exportItemXML(targetObject:DisplayObject):XML

Exports transform data (scale/rotation/position) of a particular DisplayObject in XML format so that it can be saved to a database or elsewhere easily and then reapplied later. If you'd like to export all settings and every item's data, use the exportFullXML() instead. exportItemXML() returns an XML object in the following format:

Parameters

targetObject:DisplayObject — The DisplayObject whose transform data you'd like to export.

Returns
XML — An XML object describing the targetObject's transform data (scale/rotation/position) and a few other TransformManager-related settings.

See also


Example
<item name="mc1" level="1" a="0.98" b="0" c="0" d="0.9" tx="79.2" ty="150.5" xOffset="-23.4" yOffset="-34.35" rawWidth="128.6" rawHeight="110.7" scaleMode="scaleNormal" hasSelectableText="0" minScaleX="-Infinity" maxScaleX="Infinity" minScaleY="-Infinity" maxScaleY="Infinity"/>
exportSettingsXML()method 
public function exportSettingsXML():XML

Exports the TransformManager's settings in XML format so that it can be saved to a database or elsewhere easily and then reapplied later. exportSettingsXML() returns an XML object in the following format:

Returns
XML — An XML object containing settings data about the TransformManager.

See also


Example
<settings allowDelete="1" allowMultiSelect="1" autoDeselect="1" constrainScale="0" lockScale="1" scaleFromCenter="0" lockRotation="0" lockPosition="0" arrowKeysMove="0" forceSelectionToFront="1" lineColor="3381759" handleColor="16777215" handleSize="8" paddingForRotation="12" hideCenterHandle="0"/>
getItem()method 
public function getItem($targetObject:DisplayObject):TransformItem

Gets the TransformItem associated with a particular DisplayObject (if any). This can be useful if you need to set item-specific properties like minScaleX/maxScaleX, etc.

Parameters

$targetObject:DisplayObject — The DisplayObject with which the TransformItem is associated

Returns
TransformItem — The associated TransformItem
getSelectionBounds()method 
public function getSelectionBounds(targetCoordinateSpace:DisplayObject = null):Rectangle

Gets the bounding Rectangle of the current selection (not including handles)

Parameters

targetCoordinateSpace:DisplayObject (default = null) — The display object that defines the coordinate system to use.

Returns
Rectangle — Bounding Rectangle of the current selection (not including handles)
getSelectionBoundsWithHandles()method 
public function getSelectionBoundsWithHandles(targetCoordinateSpace:DisplayObject = null):Rectangle

Gets the bounding Rectangle of the current selection (including handles)

Parameters

targetCoordinateSpace:DisplayObject (default = null) — The display object that defines the coordinate system to use.

Returns
Rectangle — Bounding Rectangle of the current selection (including handles)
getSelectionCenter()method 
public function getSelectionCenter():Point

Gets the center point of the current selection

Returns
Point — Center Point of the current selection
getUnrotatedSelectionHeight()method 
public function getUnrotatedSelectionHeight():Number

Gets the height of the selection as if it were not rotated.

Returns
Number — The unrotated selection height
getUnrotatedSelectionWidth()method 
public function getUnrotatedSelectionWidth():Number

Gets the width of the selection as if it were not rotated.

Returns
Number — The unrotated selection width
isSelected()method 
public function isSelected($item:*):Boolean

Determines whether or not a particular DisplayObject or TranformItem is currently selected.

Parameters

$item:* — The TransformItem or DisplayObject whose selection status needs to be checked

Returns
Boolean — If true, the item/DisplayObject is currently selected
moveSelection()method 
public function moveSelection($x:Number, $y:Number, $dispatchEvents:Boolean = true):void

Moves the selected items by a certain number of pixels on the x axis and y axis

Parameters

$x:Number — Number of pixels to move the selected items along the x-axis (can be negative or positive)
 
$y:Number — Number of pixels to move the selected items along the y-axis (can be negative or positive)
 
$dispatchEvents:Boolean (default = true) — If false, no MOVE Events will be dispatched

moveSelectionDepthDown()method 
public function moveSelectionDepthDown():void

Moves the selection down one level.

moveSelectionDepthUp()method 
public function moveSelectionDepthUp():void

Moves the selection up one level.

removeAllChildren()method 
override public function removeAllChildren():void

Removes all children

removeChild()method 
override public function removeChild($child:DisplayObject):DisplayObject

Removes a child DisplayObject

Parameters

$child:DisplayObject — Child to remove

Returns
DisplayObject — DisplayObject
removeChildAt()method 
override public function removeChildAt($index:int):DisplayObject

Removes a child from a particular index number in the display list

Parameters

$index:int — Index number from which to remove the child

Returns
DisplayObject — DisplayObject
removeEventListener()method 
override public function removeEventListener($type:String, $listener:Function, $useCapture:Boolean = false):void

Removes an Event listener

Parameters

$type:String — Type of Event
 
$listener:Function — Listener
 
$useCapture:Boolean (default = false) — Use capture phase

removeIgnoredObject()method 
public function removeIgnoredObject($object:DisplayObject):void

Removes an ignored DisplayObject so that its clicks are no longer ignored.

Parameters

$object:DisplayObject — DisplayObject that should not be ignored anymore

removeItem()method 
public function removeItem($item:*):void

Removes an item. Calling this on an item will NOT delete the DisplayObject - it just prevents it from being affected by this FlexTransformManager anymore.

Parameters

$item:* — Either the DisplayObject or the associated TransformItem that should be removed

removeSelectionBoxElement()method 
public function removeSelectionBoxElement(element:DisplayObject):void

Releases a DisplayObject that was attached using addSelectionBoxElement().

Parameters

element:DisplayObject — The DisplayObject to release

See also

rotateSelection()method 
public function rotateSelection($angle:Number, $dispatchEvents:Boolean = true):void

Rotates the selected items by a particular angle (in Radians). This is NOT an absolute value, so if one of the selected items' rotation property is Math.PI and you rotateSelection(Math.PI), the new angle would be Math.PI * 2.

Parameters

$angle:Number — Angle (in Radians) that should be added to the selected items' current rotation
 
$dispatchEvents:Boolean (default = true) — If false, no ROTATE events will be dispatched

scaleSelection()method 
public function scaleSelection($sx:Number, $sy:Number, $dispatchEvents:Boolean = true):void

Scales the selected items along the x- and y-axis using multipliers. Keep in mind that these are not absolute values, so if a selected item's scaleX is 2 and you scaleSelection(2, 1), its new scaleX would be 4 because 2 * 2 = 4.

Parameters

$sx:Number — Multiplier for scaling along the selection box's x-axis (which may or may not be the same as the selected item's y-axis, depending on whether or not multiple items are selected and if any are rotated)
 
$sy:Number — Multiplier for scaling along the selection box's y-axis (which may or may not be the same as the selected item's y-axis, depending on whether or not multiple items are selected and if any are rotated)
 
$dispatchEvents:Boolean (default = true) — If false, no SCALE events will be dispatched

selectItem()method 
public function selectItem($item:*, $addToSelection:Boolean = false):void

Selects a particular TransformItem or DisplayObject (you must have already added the DisplayObject to FlexTransformManager in order for it to be selectable - use addItem() for that)

Parameters

$item:* — The TransformItem or DisplayObject that should be selected
 
$addToSelection:Boolean (default = false) — If true, any currently selected items will remain selected and the new item/DisplayObject will be added to the selection.

selectItems()method 
public function selectItems($items:Array, $addToSelection:Boolean = false):void

Selects an Array of TransformItems and/or DisplayObjects. (you must have already added the DisplayObjects to FlexTransformManager in order for it to be selectable - use addItem() or addItems() for that)

Parameters

$items:Array — An Array of TransformItems and/or DisplayObjects to be selected
 
$addToSelection:Boolean (default = false) — If true, any currently selected items will remain selected and the new items/DisplayObjects will be added to the selection.

setActualSize()method 
override public function setActualSize(w:Number, h:Number):void

Parameters

w:Number
 
h:Number

updateSelection()method 
public function updateSelection($centerOrigin:Boolean = true):void

Refreshes the selection box/handles.

Parameters

$centerOrigin:Boolean (default = true) — If true, the origin (axis of rotation/scaling) will be automatically centered.

Event Detail
tmClickOff Event
Event Object Type: com.greensock.events.TransformEvent

tmDelete Event  
Event Object Type: com.greensock.events.TransformEvent

tmDepthChange Event  
Event Object Type: com.greensock.events.TransformEvent

tmDestroy Event  
Event Object Type: com.greensock.events.TransformEvent

tmDoubleClick Event  
Event Object Type: com.greensock.events.TransformEvent

tmFinishInteractiveMove Event  
Event Object Type: com.greensock.events.TransformEvent

tmFinishInteractiveRotate Event  
Event Object Type: com.greensock.events.TransformEvent

tmFinishInteractiveScale Event  
Event Object Type: com.greensock.events.TransformEvent

tmMouseDown Event  
Event Object Type: com.greensock.events.TransformEvent

tmMove Event  
Event Object Type: com.greensock.events.TransformEvent

tmReleaseCursor Event  
Event Object Type: com.greensock.events.TransformEvent

tmRotate Event  
Event Object Type: com.greensock.events.TransformEvent

tmScale Event  
Event Object Type: com.greensock.events.TransformEvent

tmSeizeCursor Event  
Event Object Type: com.greensock.events.TransformEvent

tmSelectionChange Event  
Event Object Type: com.greensock.events.TransformEvent

tmStartInteractiveMove Event  
Event Object Type: com.greensock.events.TransformEvent

tmStartInteractiveRotate Event  
Event Object Type: com.greensock.events.TransformEvent

tmStartInteractiveScale Event  
Event Object Type: com.greensock.events.TransformEvent

Constant Detail
VERSIONConstant
public static const VERSION:Number = 1.9662