Align to Center


/ Published in: ActionScript 3
Save to your folder(s)

Aligns any display object to the center od the stage


Copy this code and paste it in your HTML
  1. public static function alignToCenter(obj:DisplayObject):void
  2. {
  3. obj.x = obj.stage.stageWidth / 2 - obj.width / 2;
  4. obj.y = obj.stage.stageHeight / 2 - obj.height / 2;
  5. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.