“FlashPlatform Initialization”的版本间的差异

来自Blueidea
跳转至: 导航搜索
舞台尺寸的軟匹配:
第45行: 第45行:
 
   } // <- end class ->
 
   } // <- end class ->
 
}
 
}
 +
</syntaxhighlight>
 +
 +
通常我們會對stage做如上設定讓舞台在左上角對齊,並且當FlashPlayer尺寸設置時令縮放保持不變。
 +
<syntaxhighlight lang="actionscript">
 +
stage.align = StageAlign.TOP_LEFT;
 +
stage.scaleMode = StageScaleMode.NO_SCALE;
 
</syntaxhighlight>
 
</syntaxhighlight>

2011-04-13T22:40:26的版本

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;