Posted By

adrianparr on 01/05/11


Tagged

centre center x as3 y DisplayObject christian Cantrell


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

mitien


AS3 Center one DisplayObject relative to another


 / Published in: ActionScript 3
 

URL: http://www.adobe.com/devnet/flash/articles/authoring_for_multiple_screen_sizes.html

Taken from Christian Cantrell's Adobe article called 'Authoring mobile Flash content for multiple screen sizes'.

  1. function center(foreground:DisplayObject, background:DisplayObject):void
  2. {
  3. foreground.x = (background.width / 2) - (foreground.width / 2);
  4. foreground.y = (background.height / 2) + (foreground.height / 2);
  5. }

Report this snippet  

You need to login to post a comment.