首页 > 代码库 > Flash自适应舞台和对齐处理

Flash自适应舞台和对齐处理

普通应用:

import flash.display.StageAlign;

import flash.display.StageScaleMode;

stage.align=StageAlign.TOP_LEFT;

stage.scaleMode="noScale";

stage.addEventListener(Event.RESIZE,resizeHandler);

function resizeHandler(event:Event) {

bj.width=stage.stageWidth;

bj.height=stage.stageHeight;

}

GS应用:

import flash.display.StageAlign;

import flash.display.StageScaleMode;

import com.greensock.layout.*;

//无缩放+左上对齐

stage.scaleMode=StageScaleMode.NO_SCALE;

stage.align=StageAlign.TOP_LEFT;

//舞台元素自适应

var area:AutoFitArea=new AutoFitArea(this,0,0,stage.stageWidth,stage.stageHeight,0xff0000);

area.attach(pp1,ScaleMode.PROPORTIONAL_OUTSIDE, AlignMode.CENTER, AlignMode.CENTER);

area.preview=true;

//舞台元素对齐处理

var ls:LiquidStage=new LiquidStage(this.stage,800,555,800,555);

ls.attach(pp2, ls.RIGHT_CENTER);

ls.attach(pp3, ls.LEFT_CENTER);