http://www.helmutgranda.com/2008/02/11/stop-sound-of-loaded-swfs-in-as3/
I found this code through google search. I tried adapting it to my current code and I’m having trouble. Is it because this essentially creates a new class?
Here is my code without the mute option:
import flash.media.SoundTransform;
import flash.display.Loader;
var imageLoader:Loader;
function loadImage(url:String):void {
// Show Preloader
preloader.visible = true;
// Set properties on my Loader object
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
loadImage("swfs/pul.swf");
function imageLoaded(e:Event):void {
// Load Image
imageLoadArea.addChild(imageLoader);
imageLoader.name = "pulmi";
imageLoader.width = 320;
imageLoader.height = 280;
// Hide Preloader
preloader.visible = false;
}
function imageLoading(e:ProgressEvent):void {
// Get current download progress
var loaded:Number = e.bytesLoaded / e.bytesTotal;
// Send progress info to "preloader" movie clip
preloader.SetProgress(loaded);
}
I would think that I could just create a new SoundTransform and then apply it to my movieClip
function imageLoaded(e:Event):void {
// Load Image
imageLoadArea.addChild(imageLoader);
imageLoader.name = "pulmi";
imageLoader.width = 320;
imageLoader.height = 280;
// Hide Preloader
preloader.visible = false;
var mySoundTransform = new SoundTransform();
mySoundTransform.volume = 0;
imageLoader.soundTransform = mySoundTransform;
}
But I get this error:
1119: Access of possibly undefined property soundTransform through a reference with static type flash.display:Loader.