A Sprite wrapper class that allows one to programatically set a registration point on a display object without the use of the flash IDE.
Options:
- TL - Top Left
- TC - Top Center
- TR - Top Right
- CL - Center Left
- C - Center
- CR - Center Right
- BL - Bottom Left
- BC - Bottom Center
- BR - Bottom Right
- x/y - x/y coordinates
Usage:
var squareBox:Sprite = new Sprite();
squareBox.graphics.beginFill(0xFF0000);
squareBox.graphics.drawRect(0,0,100,100);
var centeredSprite:Sprite = new SpriteRegPoint("C");
centeredSprite.addChild(squareBox);
addChild(centeredSprite);
centeredSprite.rotation = 45;
graphics:Graphics [read-only]
Implementation
public function get graphics():Graphics
numChildren:int [read-only]
Implementation
public function get numChildren():int
public function SpriteRegPoint(registrationPoint:String = null, xReg:Number, yReg:Number)
If the registrationPoint parameter is set, sets a registration point similar to the way it is set in the flash ide.
If xReg and yReg, sets X,Y registration coordinates. Does not auto update, since hardcoded coordinates are used.
Note: When using graphics classes call this after you're done drawing, call updateRegistrationPoint to update the registration point.
Parameters
| registrationPoint:String (default = null) — - Options are "TL", "TC", "TR", "CL", "C", "CR", "BL", "BC", and "BR"
|
| |
| xReg:Number — - x registration point coordinate
|
| |
| yReg:Number — - y registration point coordinate
|
public override function addChild(child:DisplayObject):DisplayObject
Parameters
Returns
public override function addChildAt(child:DisplayObject, index:int):DisplayObject
Parameters
| child:DisplayObject |
| |
| index:int |
Returns
public override function contains(child:DisplayObject):Boolean
Parameters
Returns
public override function getChildAt(index:int):DisplayObject
Parameters
Returns
public override function getChildByName(name:String):DisplayObject
Parameters
Returns
public override function getChildIndex(child:DisplayObject):int
Parameters
Returns
public override function removeChild(child:DisplayObject):DisplayObject
Parameters
Returns
public override function removeChildAt(index:int):DisplayObject
Parameters
Returns
public override function setChildIndex(child:DisplayObject, index:int):void
Parameters
| child:DisplayObject |
| |
| index:int |
public function setRegistrationCoords(xReg:int, yReg:int):void
Sets X,Y registration coordinates. Does not auto update, since hardcoded coordinates are used.
Parameters
| xReg:int — - x registration point coordinate
|
| |
| yReg:int — - y registration point coordinate
|
public function setRegistrationPoint(registrationPoint:String):void
Sets a registration point similar to the way it is set in the flash ide.
Parameters
| registrationPoint:String — Options are "TL", "TC", "TR", "CL", "C", "CR", "BL", "BC", and "BR"
|
public override function swapChildren(child1:DisplayObject, child2:DisplayObject):void
Parameters
| child1:DisplayObject |
| |
| child2:DisplayObject |
public override function swapChildrenAt(index1:int, index2:int):void
Parameters
public function updateRegistrationPoint():void
When using graphics classes call this after you're done drawing to update the registration point.