Posted By

ricosushi on 07/17/10


Tagged

center stage


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ricosushi


Center movieclip to stage


 / Published in: ActionScript
 

Centers the main_MC movieclip when stage is resized

  1. // set up
  2. Stage.align = "TL";
  3. Stage.scaleMode = "noScale";
  4.  
  5. // function
  6. function center() {
  7. var xPos = Stage.width/2 - main_MC._width/2;
  8. var yPos = Stage.height/2 - main_MC._height/2;
  9. main_MC._x = xPos;
  10. main_MC._y = yPos;
  11. }
  12.  
  13.  
  14. // listener
  15. var centerListener = new Object();
  16. Stage.addListener(centerListener);
  17. centerListener.onResize = function() {
  18. center();
  19. };
  20.  
  21. //default center
  22. center();

Report this snippet  

You need to login to post a comment.