/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import flash.events.*; stop(); stage.addEventListener(Event.ENTER_FRAME, setStage); stage.addEventListener(Event.RESIZE, setStage); function setStage(event:Event):void { mainMovie.x = (stage.stageWidth / 2) - (mainMovie.width / 2); mainMovie.y = (stage.stageHeight / 2) - (mainMovie.height / 2); mainBg.x = (stage.stageWidth / 2) - (1920 / 2); mainBg.y = (stage.stageHeight / 2) - (1200 / 2); } // mainMovie (Movie Clip) is the whole movie which gets centered // mainBg (Movie Clip) is the background which gets also centered