Posted By

allnatural on 03/13/09


Tagged

resize center


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

vip4lyf
damarev
TrentSkunk
greguarr


Dynamically Center MovieClip on Event.RESIZE


 / Published in: ActionScript 3
 

  1. import flash.display.StageAlign;
  2. import flash.display.StageScaleMode;
  3. import flash.events.Event;
  4.  
  5. function resizeHandler(e:Event):void
  6. {
  7. mySampleMC.x = (mySampleMC.stage.stageWidth / 2) - (mySampleMC.width / 2);
  8. mySampleMC.y = (mySampleMC.stage.stageHeight / 2) - (mySampleMC.height / 2);
  9. }
  10.  
  11. stage.align = StageAlign.TOP_LEFT;
  12. stage.scaleMode = StageScaleMode.NO_SCALE;
  13. stage.addEventListener(Event.RESIZE, resizeHandler);
  14.  
  15. stage.dispatchEvent(new Event(Event.RESIZE)); // center initially

Report this snippet  

You need to login to post a comment.