AS3负荷,播放和静音外部SWF [英] as3 load, play and mute external swf

查看:102
本文介绍了AS3负荷,播放和静音外部SWF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件,我没有源 - 有一个讨厌的声音介绍闪光头,我需要静音的所有声音。没有源本人水平有限,以什么我能做的。我有我使用尝试并加载到SWF和静音(建设中的FlashDevelop)一些AS3 code。这里是code的问题:

I have a file to which I do not have the source - a flash header with an obnoxious sound intro and I need to mute all sounds. Without the source I am limited as to what I can do. I have some as3 code that I am using to try and load the swf into and mute(building in FlashDevelop). Here is the code in question:

package 
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.media.SoundTransform;

public class Main extends Sprite 
{
    private var mLoader:Loader;
    private var mc1:MovieClip;
    private var holder:Sprite;
    private var mSound:SoundTransform;

    public function Main():void 
    {
        if (stage) init();
        else addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init(e:Event = null):void 
    {
        var mRequest:URLRequest = new URLRequest('header_v8.swf');
        mLoader = new Loader();
        mLoader.load(mRequest);
        holder = new Sprite();
        holder.addChild(mLoader);
        addChild(holder);
        mSound = new SoundTransform(0);
        holder.soundTransform = mSound;

    }

}

}

这code以上仍然播放音频和未显示原始瑞士法郎。所以,我的问题是:

This code above still plays the audio and the original swf is not being displayed. So, my questions are:

我将如何静音外部音频? 我将如何显示只是因为它不直接看到它时,外部SWF?

How would I mute the external audio? How would I display the external swf just as it does when viewing it directly?

有用的例子任何建议或指针/文件将大大AP preciated

Any suggestions or pointers to useful examples/documentation would be greatly appreciated

推荐答案

您运行此在调试播放器?看你的code,现在看来,这应该抛出至少一个错误在该行:

Are you running this in a debug player? Looking at your code, it seems it should throw at least an Error at this line:

holder.addChild(mLoader);

这似乎是不是在这一点上初始化。也许有你没有看到,打破你的code错误...的$ C $下静音期待权(虽然我还没有尝试过)。也许你可以把它应用到了,而不是内容本身;否则,将有可能是你的头SWF加载部分,并开始播放声音的完整的处理程序被调用之前。

It seems holder is not initialized at that point. Maybe there's an error you're not seeing that breaks your code... The code for muting the sound looks right (though I haven't tried it). Maybe you could apply it to the holder instead of the content itself; otherwise it would be possible that your header swf loaded partially and started to play back sounds before your complete handler is called.

此外 SoundMixer 让你控制全局卷(我说出来,因为虽然它可能不是这样的理想方式,或许它只是在这里工作)。

Also SoundMixer lets you control the global volume (I mention it because although it might not be the ideal way of doing this, maybe it just works here).

修改

这有效地在静音的快速测试我做了加载的SWF:

This effectively mutes the loaded swf in a quick test I did:

var mRequest:URLRequest = new URLRequest('banner.swf');
var mLoader:Loader = new Loader();
mLoader.load(mRequest);
var holder:Sprite = new Sprite();
holder.addChild(mLoader);
addChild(holder);
var t:SoundTransform = new SoundTransform(0);
holder.soundTransform = t;

我删除了完整的处理程序,因为它不再需要。

I removed the complete handler, since it's not needed anymore.

这篇关于AS3负荷,播放和静音外部SWF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆