FlashPlatform Initialization

来自Blueidea
enc0717讨论 | 贡献2011-04-13T22:37:38的版本

跳转至: 导航搜索

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 ->
}