【问题标题】:How to apply dynamically scale down and up into a thumbnail images size?如何动态应用缩小和放大到缩略图大小?
【发布时间】:2010-06-09 13:24:04
【问题描述】:

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

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

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

【问题讨论】:

    标签: flash resize scale actionscript-3


    【解决方案1】:

    如果您可以编辑加载的 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 的影片剪辑

    【讨论】:

    • 如何缩放动态加载另一个swf的movieclip?
    • 在 HTML 中将主 swf 的大小设置为 100%(使用 %,而不是像素!)在主电影中添加:stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT;然后你可以在你的主电影中调整对象(mcs等)的大小,当然不是电影本身。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-28
    • 2015-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多