Return to Kroll Design home page

Flash Tutorials (with .FLA files included)

« Return

ActionScript 3

Registration point

When drawing a shape, whether with drawRect or drawCirc, the first two parms are the x and y offset from the 0,0 registration point. If you expect for objects added near this shape to line up with the upper left corner of the object, make sure to have the registration point of the initial object be 0,0, as shown with the square on the left in the example below.

Download the FLA file

  Create a cyan sprite directly on its registration point. The registration point is indicated by a small yellow circle.

var cyanSquare:Sprite = new Sprite();;,0,80,80);
cyanSquare.x = 20;
cyanSquare.y = 20;

var cyanSquareRegistration:Sprite = new Sprite();;,0,5);

  Create a red sprite 10 pixels to the right and below its registration point.
	The registration point is indicated by the small yellow circle.

var redSquare:Sprite = new Sprite();;,10,80,80); // Note the "10, 10"
redSquare.x = 160;
redSquare.y = 20;

var redSquareRegistration:Sprite = new Sprite();;,0,5);

« Return

©2012 Kroll Design    781.910.3694
Last modified: 12/31/1969 7:00 PM