Package | com.greensock.transform |
Class | public class TransformItem |
Inheritance | TransformItem flash.events.EventDispatcher |
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.
Property | Defined 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 |
Method | Defined 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 | ||
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 |
allowDelete | property |
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
]
public function get allowDelete():Boolean
public function set allowDelete(value:Boolean):void
alpha | property |
alpha:Number
alpha
public function get alpha():Number
public function set alpha(value:Number):void
center | property |
center:Point
[read-only] Center point (according to the DisplayObject.parent's coordinate space
public function get center():Point
constrainScale | property |
constrainScale:Boolean
To constrain the item so that it only scales proportionally, set this to true [default: false
]
public function get constrainScale():Boolean
public function set constrainScale(value:Boolean):void
enabled | property |
enabled:Boolean
Enable or disable the TransformItem.
public function get enabled():Boolean
public function set enabled(value:Boolean):void
hasSelectableText | property |
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
.
public function get hasSelectableText():Boolean
public function set hasSelectableText(value:Boolean):void
hasSizeLimits | property |
hasSizeLimits:Boolean
[read-only] Reflects whether or not minScaleX, maxScaleX, minScaleY, or maxScaleY have been set.
public function get hasSizeLimits():Boolean
height | property |
height:Number
height
public function get height():Number
public function set height(value:Number):void
innerCenter | property |
innerCenter:Point
[read-only] Center point according to the local coordinate space
public function get innerCenter():Point
lockPosition | property |
lockPosition:Boolean
Prevents moving
public function get lockPosition():Boolean
public function set lockPosition(value:Boolean):void
lockRotation | property |
lockRotation:Boolean
Prevents rotating
public function get lockRotation():Boolean
public function set lockRotation(value:Boolean):void
lockScale | property |
lockScale:Boolean
Prevents scaling
public function get lockScale():Boolean
public function set lockScale(value:Boolean):void
manager | property |
manager:TransformManager
[read-only] The TransformManager instance to which the TransformItem belongs [read-only]
public function get manager():TransformManager
manualBoundsOffset | property |
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).
maxHeight | property |
maxHeight:Number
Maximum height (measured as if the object was unrotated). Default is Infinity.
public function get maxHeight():Number
public function set maxHeight(value:Number):void
maxScale | property |
maxScale:Number
[write-only] Maximum scale (affects both the maxScaleX and maxScaleY properties)
public function set maxScale(value:Number):void
maxScaleX | property |
maxScaleX:Number
Maximum scaleX
public function get maxScaleX():Number
public function set maxScaleX(value:Number):void
maxScaleY | property |
maxScaleY:Number
Maximum scaleY
public function get maxScaleY():Number
public function set maxScaleY(value:Number):void
maxWidth | property |
maxWidth:Number
Maximum width (measured as if the object was unrotated). Default is Infinity.
public function get maxWidth():Number
public function set maxWidth(value:Number):void
minHeight | property |
minHeight:Number
Minimum height (measured as if the object was unrotated). Default is 1 (and cannot be less than 1).
public function get minHeight():Number
public function set minHeight(value:Number):void
minScale | property |
minScale:Number
[write-only] Minimum scale (affects both the minScaleX and minScaleY properties)
public function set minScale(value:Number):void
minScaleX | property |
minScaleX:Number
Minimum scaleX
public function get minScaleX():Number
public function set minScaleX(value:Number):void
minScaleY | property |
minScaleY:Number
Minimum scaleY
public function get minScaleY():Number
public function set minScaleY(value:Number):void
minWidth | property |
minWidth:Number
Minimum width (measured as if the object was unrotated). Default is 1 (and cannot be less than 1).
public function get minWidth():Number
public function set minWidth(value:Number):void
origin | property |
origin:Point
Point that serves as the origin for scaling or axis of rotation
public function get origin():Point
public function set origin(value:Point):void
rotation | property |
rotation:Number
rotation
public function get rotation():Number
public function set rotation(value:Number):void
scaleMode | property |
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.
public function get scaleMode():String
public function set scaleMode(value:String):void
scaleX | property |
scaleX:Number
scaleX
public function get scaleX():Number
public function set scaleX(value:Number):void
scaleY | property |
scaleY:Number
scaleY
public function get scaleY():Number
public function set scaleY(value:Number):void
selected | property |
selected:Boolean
selected state of the item
public function get selected():Boolean
public function set selected(value:Boolean):void
targetObject | property |
targetObject:DisplayObject
[read-only] The associated DisplayObject
public function get targetObject():DisplayObject
width | property |
width:Number
width
public function get width():Number
public function set width(value:Number):void
x | property |
x:Number
x-coordinate
public function get x():Number
public function set x(value:Number):void
y | property |
y:Number
y-coordinate
public function get y():Number
public function set y(value:Number):void
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)} .
|
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
|