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 2010, 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
  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
Allows listening for the following events:
  • TransformEvent.MOVE
  • TransformEvent.SCALE
  • TransformEvent.ROTATE
  • TransformEvent.SELECT
  • TransformEvent.DELETE
  • TransformEvent.UPDATE
TransformItem
  
deleteObject():void
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  [read-write]

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  [read-write]

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  [read-write]

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  [read-write]

Enable or disable the TransformItem.

Implementation
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void
hasSelectableTextproperty 
hasSelectableText:Boolean  [read-write]

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  [read-write]

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  [read-write]

Prevents moving

Implementation
    public function get lockPosition():Boolean
    public function set lockPosition(value:Boolean):void
lockRotationproperty 
lockRotation:Boolean  [read-write]

Prevents rotating

Implementation
    public function get lockRotation():Boolean
    public function set lockRotation(value:Boolean):void
lockScaleproperty 
lockScale:Boolean  [read-write]

Prevents scaling

Implementation
    public function get lockScale():Boolean
    public function set lockScale(value:Boolean):void
maxHeightproperty 
maxHeight:Number  [read-write]

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  [read-write]

Maximum scaleX

Implementation
    public function get maxScaleX():Number
    public function set maxScaleX(value:Number):void
maxScaleYproperty 
maxScaleY:Number  [read-write]

Maximum scaleY

Implementation
    public function get maxScaleY():Number
    public function set maxScaleY(value:Number):void
maxWidthproperty 
maxWidth:Number  [read-write]

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  [read-write]

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  [read-write]

Minimum scaleX

Implementation
    public function get minScaleX():Number
    public function set minScaleX(value:Number):void
minScaleYproperty 
minScaleY:Number  [read-write]

Minimum scaleY

Implementation
    public function get minScaleY():Number
    public function set minScaleY(value:Number):void
minWidthproperty 
minWidth:Number  [read-write]

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  [read-write]

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  [read-write]

rotation

Implementation
    public function get rotation():Number
    public function set rotation(value:Number):void
scaleModeproperty 
scaleMode:String  [read-write]

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  [read-write]

scaleX

Implementation
    public function get scaleX():Number
    public function set scaleX(value:Number):void
scaleYproperty 
scaleY:Number  [read-write]

scaleY

Implementation
    public function get scaleY():Number
    public function set scaleY(value:Number):void
selectedproperty 
selected:Boolean  [read-write]

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  [read-write]

width

Implementation
    public function get width():Number
    public function set width(value:Number):void
xproperty 
x:Number  [read-write]

x-coordinate

Implementation
    public function get x():Number
    public function set x(value:Number):void
yproperty 
y:Number  [read-write]

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
public override 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 TargetItem'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