AS3: Controlling Registration Points Programmatically

The SpriteRegPoint Class is designed to mimic this feature in flash:

Registration Point Window

For those of you who use Flex or FlashDevelop to do all of your flash development and would like to control registration points similarly to the flash IDE, this is the class for you.

Download the Source File
View the Documentation

These are the options you can set:

  • 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;