示例
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
public class Main extends Sprite
{
//文档类主要构造函数
public function Main()
{
//有时阶段尚不可用,所以如果没有,请等待阶段再继续
if (!stage) {
addEventListener(Event.ADDED_TO_STAGE, stageReady);
}else {
stageReady();
}
}
protected function stageReady(e:Event = null):void {
//将舞台对准窗口/容器的左上角
stage.align= StageAlign.TOP_LEFT;
//调整窗口大小时不缩放内容
stage.scaleMode= StageScaleMode.NO_SCALE;
//调整窗口大小时监听
stage.addEventListener(Event.RESIZE, stageResized);
}
protected function stageResized(e:Event):void {
//usestage.stageWdith&stage.stageHeightto repostion and resize items
}
}
}