as3.0舞台自适应

来源:互联网 发布:ubuntu mount samba 编辑:程序博客网 时间:2024/04/28 23:17
import flash.display.StageScaleMode;import flash.events.Event;//先将缩放模式设置成无缩放模式stage.scaleMode = StageScaleMode.NO_SCALE;//利用Event.RESIZE 事件对stage进行大小变化监听stage.addEventListener(Event.RESIZE,doResize);function doResize(e:Event){trace(stage.stageWidth);//确保 left_top 始终在左上角left_top.x = -(stage.stageWidth - 550) / 2;//550是舞台大小——宽left_top.y = -(stage.stageHeight - 400) / 2;//400是舞台大小——高//确保 right_top 始终在右上角位置right_top.x = -(stage.stageWidth - 550) / 2 + stage.stageWidth - right_top.width;right_top.y = -(stage.stageHeight - 400) / 2;//确保 left_bottom 始终在左下角left_bottom.x = -(stage.stageWidth - 550) / 2;left_bottom.y = -(stage.stageHeight - 400) / 2 + stage.stageHeight - left_bottom.height;//确保 right_bottom 始终在右下角位置right_bottom.x = -(stage.stageWidth - 550) / 2 + stage.stageWidth - right_bottom.width;right_bottom.y = -(stage.stageHeight - 400) / 2 + stage.stageHeight - right_bottom.height;}

0 0