Packagecom.greensock.transform
Classpublic class TransformItem
InheritanceTransformItem Inheritance flash.events.EventDispatcher

TransformManager automatically creates a TransformItem instance for each DisplayObject that it manages, using it to apply various transformations and check constraints. Typically you won't need to interact much with the TranformItem instances except if you need to apply item-specific properties like minScaleX, maxScaleX, minScaleY, maxScaleY, or if you need to apply transformations directly. You can use TransformManager's getItem() method to get the TransformItem instance associated with a particular DisplayObject anytime after it is added to the TransformManager instance, like:

var myItem:TransformItem = myManager.getItem(myObject);

Copyright 2007-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 while this item is selected, it will be deleted (unless hasSelectableText is set to true) [default: false]
TransformItem
  alpha : Number
alpha
TransformItem
  center : Point
[read-only] Center point (according to the DisplayObject.parent's coordinate space
TransformItem
  constrainScale : Boolean
To constrain the item so that it only scales proportionally, set this to true [default: false]
TransformItem
  enabled : Boolean
Enable or disable the TransformItem.
TransformItem
  hasSelectableText : Boolean
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.
TransformItem
  hasSizeLimits : Boolean
[read-only] Reflects whether or not minScaleX, maxScaleX, minScaleY, or maxScaleY have been set.
TransformItem
  height : Number
height
TransformItem
  innerCenter : Point
[read-only] Center point according to the local coordinate space
TransformItem
  lockPosition : Boolean
Prevents moving
TransformItem
  lockRotation : Boolean
Prevents rotating
TransformItem
  lockScale : Boolean
Prevents scaling
TransformItem
  manager : TransformManager
[read-only] The TransformManager instance to which the TransformItem belongs [read-only]
TransformItem
  manualBoundsOffset : Rectangle
Should only be used in cases where the selection box is drawn incorrectly on a single-selection of the TransformItem (typically due to bugs in Adobe's Flex framework) - this allows you to define the amount of pixels to offset from the registration and the width/height of the targetObject when drawing the selection box around the single selection of the TransformItem.
TransformItem
  maxHeight : Number
Maximum height (measured as if the object was unrotated).
TransformItem
  maxScale : Number
[write-only] Maximum scale (affects both the maxScaleX and maxScaleY properties)
TransformItem
  maxScaleX : Number
Maximum scaleX
TransformItem
  maxScaleY : Number
Maximum scaleY
TransformItem
  maxWidth : Number
Maximum width (measured as if the object was unrotated).
TransformItem
  minHeight : Number
Minimum height (measured as if the object was unrotated).
TransformItem
  minScale : Number
[write-only] Minimum scale (affects both the minScaleX and minScaleY properties)
TransformItem
  minScaleX : Number
Minimum scaleX
TransformItem
  minScaleY : Number
Minimum scaleY
TransformItem
  minWidth : Number
Minimum width (measured as if the object was unrotated).
TransformItem
  origin : Point
Point that serves as the origin for scaling or axis of rotation
TransformItem
  rotation : Number
rotation
TransformItem
  scaleMode : String
Either TransformManager.SCALE_NORMAL for normal scaleX/scaleY scaling or TransformManager.SCALE_WIDTH_AND_HEIGHT if you prefer that TransformManager alters the width/height properties instead.
TransformItem
  scaleX : Number
scaleX
TransformItem
  scaleY : Number
scaleY
TransformItem
  selected : Boolean
selected state of the item
TransformItem
  targetObject : DisplayObject
[read-only] The associated DisplayObject
TransformItem
  width : Number
width
TransformItem
  x : Number
x-coordinate
TransformItem
  y : Number
y-coordinate
TransformItem
Public Methods
 MethodDefined By
  
TransformItem($targetObject:DisplayObject, $vars:Object)
Constructor
TransformItem
  
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.SELECT TransformEvent.DELETE TransformEvent.UPDATE
TransformItem
  
Deletes the DisplayObject (removing it from the display list)
TransformItem
  
destroy():void
Destroys the TransformItem instance, preparing for garbage collection
TransformItem
  
fitInsideBounds(move:Boolean = true, updateFirst:Boolean = true, customBounds:Rectangle = null):void
Immediately applies bounds to the targetObject, forcing it to stay within the bounds by scaling it down (if necessary) and optionally moving it as well.
TransformItem
  
move($x:Number, $y:Number, $checkBounds:Boolean = true, $dispatchEvent:Boolean = true):void
Moves the selected items by a certain number of pixels on the x axis and y axis
TransformItem
  
rotate($angle:Number, $checkBounds:Boolean = true, $dispatchEvent:Boolean = true):void
Rotates the item by a particular angle (in Radians).
TransformItem
  
scale($sx:Number, $sy:Number, $angle:Number = 0, $checkBounds:Boolean = true, $dispatchEvent:Boolean = true):void
Scales the item along the x- and y-axis using multipliers.
TransformItem
  
setScaleConstraints($minScaleX:Number, $maxScaleX:Number, $minScaleY:Number, $maxScaleY:Number):void
Sets minimum scaleX, maximum scaleX, minimum scaleY, and maximum scaleY
TransformItem
Property Detail
allowDeleteproperty
allowDelete:Boolean

If true, when the user presses the DELETE (or BACKSPACE) key while this item is selected, it will be deleted (unless hasSelectableText is set to true) [default: false]


Implementation
    public function get allowDelete():Boolean
    public function set allowDelete(value:Boolean):void
alphaproperty 
alpha:Number

alpha


Implementation
    public function get alpha():Number
    public function set alpha(value:Number):void
centerproperty 
center:Point  [read-only]

Center point (according to the DisplayObject.parent's coordinate space


Implementation
    public function get center():Point
constrainScaleproperty 
constrainScale:Boolean

To constrain the item so that it only scales proportionally, set this to true [default: false]


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

Enable or disable the TransformItem.


Implementation
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void
hasSelectableTextproperty 
hasSelectableText:Boolean

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.


Implementation
    public function get hasSelectableText():Boolean
    public function set hasSelectableText(value:Boolean):void
hasSizeLimitsproperty 
hasSizeLimits:Boolean  [read-only]

Reflects whether or not minScaleX, maxScaleX, minScaleY, or maxScaleY have been set.


Implementation
    public function get hasSizeLimits():Boolean
heightproperty 
height:Number

height


Implementation
    public function get height():Number
    public function set height(value:Number):void
innerCenterproperty 
innerCenter:Point  [read-only]

Center point according to the local coordinate space


Implementation
    public function get innerCenter():Point
lockPositionproperty 
lockPosition:Boolean

Prevents moving


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

Prevents rotating


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

Prevents scaling


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

The TransformManager instance to which the TransformItem belongs [read-only]


Implementation
    public function get manager():TransformManager
manualBoundsOffsetproperty 
public var manualBoundsOffset:Rectangle

Should only be used in cases where the selection box is drawn incorrectly on a single-selection of the TransformItem (typically due to bugs in Adobe's Flex framework) - this allows you to define the amount of pixels to offset from the registration and the width/height of the targetObject when drawing the selection box around the single selection of the TransformItem. For example, if the selection should be drawn as though its top-left corner is exactly on the targetObject's registration point and the width and height should be an extra 2 pixels beyond the normal width/height, you'd define the manualBoundsOffset as new Rectangle(0, 0, 2, 2). These values are relative to the registration point and are in the coordinate space of the targetObject itself (not its parent).

maxHeightproperty 
maxHeight:Number

Maximum height (measured as if the object was unrotated). Default is Infinity.


Implementation
    public function get maxHeight():Number
    public function set maxHeight(value:Number):void
maxScaleproperty 
maxScale:Number  [write-only]

Maximum scale (affects both the maxScaleX and maxScaleY properties)


Implementation
    public function set maxScale(value:Number):void
maxScaleXproperty 
maxScaleX:Number

Maximum scaleX


Implementation
    public function get maxScaleX():Number
    public function set maxScaleX(value:Number):void
maxScaleYproperty 
maxScaleY:Number

Maximum scaleY


Implementation
    public function get maxScaleY():Number
    public function set maxScaleY(value:Number):void
maxWidthproperty 
maxWidth:Number

Maximum width (measured as if the object was unrotated). Default is Infinity.


Implementation
    public function get maxWidth():Number
    public function set maxWidth(value:Number):void
minHeightproperty 
minHeight:Number

Minimum height (measured as if the object was unrotated). Default is 1 (and cannot be less than 1).


Implementation
    public function get minHeight():Number
    public function set minHeight(value:Number):void
minScaleproperty 
minScale:Number  [write-only]

Minimum scale (affects both the minScaleX and minScaleY properties)


Implementation
    public function set minScale(value:Number):void
minScaleXproperty 
minScaleX:Number

Minimum scaleX


Implementation
    public function get minScaleX():Number
    public function set minScaleX(value:Number):void
minScaleYproperty 
minScaleY:Number

Minimum scaleY


Implementation
    public function get minScaleY():Number
    public function set minScaleY(value:Number):void
minWidthproperty 
minWidth:Number

Minimum width (measured as if the object was unrotated). Default is 1 (and cannot be less than 1).


Implementation
    public function get minWidth():Number
    public function set minWidth(value:Number):void
originproperty 
origin:Point

Point that serves as the origin for scaling or axis of rotation


Implementation
    public function get origin():Point
    public function set origin(value:Point):void
rotationproperty 
rotation:Number

rotation


Implementation
    public function get rotation():Number
    public function set rotation(value:Number):void
scaleModeproperty 
scaleMode:String

Either TransformManager.SCALE_NORMAL for normal scaleX/scaleY scaling or TransformManager.SCALE_WIDTH_AND_HEIGHT if you prefer that TransformManager alters the width/height properties instead.


Implementation
    public function get scaleMode():String
    public function set scaleMode(value:String):void
scaleXproperty 
scaleX:Number

scaleX


Implementation
    public function get scaleX():Number
    public function set scaleX(value:Number):void
scaleYproperty 
scaleY:Number

scaleY


Implementation
    public function get scaleY():Number
    public function set scaleY(value:Number):void
selectedproperty 
selected:Boolean

selected state of the item


Implementation
    public function get selected():Boolean
    public function set selected(value:Boolean):void
targetObjectproperty 
targetObject:DisplayObject  [read-only]

The associated DisplayObject


Implementation
    public function get targetObject():DisplayObject
widthproperty 
width:Number

width


Implementation
    public function get width():Number
    public function set width(value:Number):void
xproperty 
x:Number

x-coordinate


Implementation
    public function get x():Number
    public function set x(value:Number):void
yproperty 
y:Number

y-coordinate


Implementation
    public function get y():Number
    public function set y(value:Number):void
Constructor Detail
TransformItem()Constructor
public function TransformItem($targetObject:DisplayObject, $vars:Object)

Constructor

Parameters
$targetObject:DisplayObject — DisplayObject to be managed
 
$vars:Object — An object specifying any properties that should be set upon instantiation, like {constrainScale:true, lockRotation:true, bounds:new Rectangle(0, 0, 500, 300)}.
Method Detail
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

deleteObject()method 
public function deleteObject():void

Deletes the DisplayObject (removing it from the display list)

destroy()method 
public function destroy():void

Destroys the TransformItem instance, preparing for garbage collection

fitInsideBounds()method 
public function fitInsideBounds(move:Boolean = true, updateFirst:Boolean = true, customBounds:Rectangle = null):void

Immediately applies bounds to the targetObject, forcing it to stay within the bounds by scaling it down (if necessary) and optionally moving it as well. If, for example, the targetObject is much larger than the bounds, it will be scaled down to fit within them. If it is positioned outside the bounds, fitInsideBounds(true) will move it only as much as is necessary for it to fit within the bounds. Applying bounds with fitInsideBounds() is NOT the same thing as setting the bounds property - fitInsideBounds() is only temporary and does not set the TransformItem's bounds property. fitInsideBounds() will never scale an object up - it will only shrink objects and/or move them.

Parameters

move:Boolean (default = true) — If true (the default), the targetObject's position will change if necessary in order to fit within the bounds.
 
updateFirst:Boolean (default = true) — If true (the default), update() will be called first before applying the bounds. This will ensure that any changes that were made manually to the targetObject are taken into account and that the targetObject's size/position/rotation/proportions are calibrated.
 
customBounds:Rectangle (default = null) — Normally, fitInsideBounds() uses the TransformItem's bounds property, but if you'd like it to use a custom Rectangle instead, define it here. Use null in order to apply the TransformItem's normal bounds that were likely set through its TransformManager.

move()method 
public function move($x:Number, $y:Number, $checkBounds:Boolean = true, $dispatchEvent: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 item along the x-axis (can be negative or positive)
 
$y:Number — Number of pixels to move the item along the y-axis (can be negative or positive)
 
$checkBounds:Boolean (default = true) — If false, bounds will be ignored
 
$dispatchEvent:Boolean (default = true) — If false, no MOVE events will be dispatched

rotate()method 
public function rotate($angle:Number, $checkBounds:Boolean = true, $dispatchEvent:Boolean = true):void

Rotates the item by a particular angle (in Radians). This is NOT an absolute value, so if one of the item's 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 item's current rotation
 
$checkBounds:Boolean (default = true) — If false, bounds will be ignored
 
$dispatchEvent:Boolean (default = true) — If false, no ROTATE events will be dispatched

scale()method 
public function scale($sx:Number, $sy:Number, $angle:Number = 0, $checkBounds:Boolean = true, $dispatchEvent:Boolean = true):void

Scales the item along the x- and y-axis using multipliers. Keep in mind that these are not absolute values, so if the item's scaleX is 2 and you scale(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)
 
$angle:Number (default = 0) — Angle at which the item should be scaled (in Radians)
 
$checkBounds:Boolean (default = true) — If false, bounds will be ignored
 
$dispatchEvent:Boolean (default = true) — If false, no SCALE event will be dispatched

setScaleConstraints()method 
public function setScaleConstraints($minScaleX:Number, $maxScaleX:Number, $minScaleY:Number, $maxScaleY:Number):void

Sets minimum scaleX, maximum scaleX, minimum scaleY, and maximum scaleY

Parameters

$minScaleX:Number — Minimum scaleX
 
$maxScaleX:Number — Maximum scaleX
 
$minScaleY:Number — Minimum scaleY
 
$maxScaleY:Number — Maximum scaleY