如何动态缩放到缩略图图像大小?

时间:2010-06-09 13:24:05

标签: flash resize scale actionscript-3

我正在开发一个当前项目,我没有任何问题将SWF加载到主SWF中但是我无法弄清楚如何在使用时动态缩放缩小图像尺寸Resize事件处理程序适合任何浏览器大小。

我将SWF加载到Loader对象中,然后将其添加到容器中=> currentMC。 我想调整它的大小并将所有部分保留在此容器中。因此,无论浏览器大小如何,我只想在其上应用缩放以适应它。

有谁知道怎么做?我将如何处理stageWidth和stageHeight? 任何代码示例都会对我有所帮助。

1 个答案:

答案 0 :(得分: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的动画片段缩放到