Put the code below on the first frame of your flash movie. Add a movieclip to stage and give it the instance name “myMovie”. This AS3 code will dynamically center your movieclip based on browser size.
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
function resizeHandler(e:Event):void
{
myMovie.x = (myMovie.stage.stageWidth / 2) - (myMovie.width / 2);
myMovie.y = (myMovie.stage.stageHeight / 2) - (myMovie.height / 2);
}
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, resizeHandler);
stage.dispatchEvent(new Event(Event.RESIZE));
//the end |
Tags: align movieclip in window, as3, center movieclip on stage, center object based on browser size
No comments yet.
Leave a comment
You must be logged in to post a comment.