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;
}
}
}
This code above still plays the audio and the original swf is not being displayed. So, my questions are:
How would I mute the external audio?
How would I display the external swf just as it does when viewing it directly?
Any suggestions or pointers to useful examples/documentation would be greatly appreciated
Are you running this in a debug player? Looking at your code, it seems it should throw at least an Error at this line:
It seems
holderis 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 theholderinstead 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.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).
Edit
This effectively mutes the loaded swf in a quick test I did:
I removed the complete handler, since it’s not needed anymore.