0

我正在处理一个当前项目,将 SWF 加载到主 SWF 中没有任何问题,但我不知道如何在使用 Resize 事件时动态地将缩放应用到缩略图大小处理程序以适应任何浏览器大小。

我将 SWF 加载到 Loader 对象中,然后将其添加到容器中 => currentMC。我想调整它的大小并将所有部件都保存在这个容器中。因此,无论浏览器大小如何,我都希望能够在其上应用比例以适应它。

有谁知道这是怎么做到的吗?我将如何处理 stageWidth 和 stageHeight?任何代码示例都会对我有很大帮助。

4

1 回答 1

0

如果您可以编辑加载的 swf,请将此代码放入 LOADED swf 中:

if (stage==null) { //first we need to wait till the stage is initialized
    addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
} else {
    onAddedToStage();
}

function onAddedToStage(event:Event=null):void {
    stage.addEventListener(Event.RESIZE, updateGUI); //resize something everytime we resize our browser window
    updateGUI(); //resize for the first time
}

function updateGUI(event:Event=null):void {
   //scale what you need
   //you can access the *stage* variable from inside the loaded swf, for eg.
   square.width = stage.stageWidth/4;
}

如果没有,请尝试缩放您加载另一个 swf 的影片剪辑

于 2010-06-22T01:16:34.777 回答