1. 程式人生 > >AS3.0 滿螢幕自適應方法

AS3.0 滿螢幕自適應方法

網上AS3.0自適應網頁的列子不多,所以自己做一個

html方面

使用釋出以後在body中的<param>標籤和<embed>標籤的width和height屬性都改為100%,<script>標籤中的width和height屬性改為100%,<noscript>標籤刪除。

flash方面

var fullmc:MovieClip=new full();
stage.scaleMode = StageScaleMode.NO_SCALE;//

stage.align = StageAlign.TOP_LEFT;//
stage.addEventListener(Event.RESIZE, resizeHandler);//resize偵聽
addChild(fullmc);
fullmc.width=stage.stageWidth;//初始化fullmc寬度
 fullmc.height=stage.stageHeight;//初始化fullmc高度
 fullmc.x=stage.stageWidth/2;//初始化X軸
   fullmc.y=stage.stageHeight/2;//初始化Y軸
function resizeHandler(e:Event):void//偵聽函式
{
 fullmc.width=stage.stageWidth;
 fullmc.height=stage.stageHeight;
 fullmc.x=stage.stageWidth/2;
   fullmc.y=stage.stageHeight/2;
}