Fullscreen center


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



Copy this code and paste it in your HTML
  1. import flash.events.*;
  2.  
  3. stop();
  4.  
  5. stage.addEventListener(Event.ENTER_FRAME, setStage);
  6. stage.addEventListener(Event.RESIZE, setStage);
  7.  
  8. function setStage(event:Event):void
  9. {
  10. mainMovie.x = (stage.stageWidth / 2) - (mainMovie.width / 2);
  11. mainMovie.y = (stage.stageHeight / 2) - (mainMovie.height / 2);
  12.  
  13. mainBg.x = (stage.stageWidth / 2) - (1920 / 2);
  14. mainBg.y = (stage.stageHeight / 2) - (1200 / 2);
  15. }
  16.  
  17.  
  18. // mainMovie (Movie Clip) is the whole movie which gets centered
  19. // mainBg (Movie Clip) is the background which gets also centered

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.