FlashPlatform Initialization
来自Blueidea
Flash platform 應用初始化常用設置。
舞台尺寸的軟匹配:
/* ~~ Blueidea wiki [Category:Flash platform]~~ www.blueidea.com */ package { import flash.display.Shape; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; // ${1} /** * The <code>Molehill</code> class.<br/> */ public class Test extends Sprite { //========================================================================== // Constructor //========================================================================== /** Constructor */ public function Test() { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; // 待會用來填充舞台。 $shape = new Shape(); repaintBorder(stage.stageWidth, stage.stageHeight); stage.addEventListener(Event.RESIZE, stage_resizeHandler); } private var $border:Shape; private function repaintBorder(width:uint, height:uint):void { // ${2} } //========================================================================== // Event listeners //========================================================================== private function stage_resizeHandler(event:Event):void { repaintBorder(stage.stageWidth, stage.height); } } // <- end class -> }
通常我們會對stage做如上設定讓舞台在左上角對齊,並且當FlashPlayer尺寸設置時令縮放保持不變。
stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE;