I have a sound problem. I have a flash (swf) file loaded within another flash (my main swf).
I want to mute all the loaded swf sounds. I successfully muted "timeline" sounds (with the soundTransform of the loader object) but my issue is with runtime played sounds.
If the sound is played using actionscript (and not manually droped on the stage using flash and the timeline), soundTransform won't apply.
I think I can't use SoundMixer since it would mute my main SWF sound too.
I've been working on this for a week and I would gladly appreciate your help.
Thank you!
there's a difference between stopping a sound and muting a sound. muting means to assign a sounds volume to zero (but the sound will still play if it's been started). stopping means the volume hasn't changed but the sound has stopped.
SoundMixer.stopAll() won't mute your main swf sounds. it will stop them. so, if any main swf sounds are playing while your loaded swf's sound is playing and you don't want to stop the main swf sounds, SoundMixer.stopAll() won't work for you. otherwise, it will.
if you want to stop loaded sounds when the loaded swf is unloaded, use unloadAndStop() (fp10+).
if you want to control the volume of a loaded sound and there's a soundchannel defined for the sound, use it. if there's no soundchannel for the loaded sound, you cannot control that sounds volume. you can close the stream if the sound in the loaded swf is itself loaded and open but otherwise cannot control individual sounds in the loaded swf.
As I said, I don't want to unload the loaded SWF, just mute the sounds it is playing (both on a timeline or an actionscript way).
I load third party projects, so I don't know how they use sound and want my "shell" to work on any case. This is about video advertising display.
When I mentioned soundMixer, I was talking about "SoundMixer.soundTransform".
Since I dont know how the loaded SWF works, I just want to handle it in a "black box" way, and I'm looking for a function allowing me to mute all the sounds items playing inside a loaded SWF.
again, if there's no soundchannel for the loaded (or any other) sound, you cannot control that sound's volume. you can close the stream if the sound in the loaded swf is itself loaded and open but otherwise cannot control individual sounds in the loaded swf.
if there is a loaded soundchannel, you can find it (using actionscript) and use it. but if you do not know if a soundchannel exists, the best you can do is to find sounds, stop them if they are still streaming, restart them with a soundchannel and then mute them.
but most people can just stop all sounds. does that work for you?
if the sound is defined in a class, i don't see any way to access it.
if the sound is defined on a timeline, you can use:
function findObjectF(mc:MovieClip,classS:String):Array{
var i:int;
var dobj:DisplayObject;
var a:Array = [];
var xml:XML = describeType(mc);
var xmlList:XMLList = xml.variable.(@type==classS);
a.push(xmlList);
var findF:Function=function(mc1:MovieClip):void{
xml = describeType(mc1);
xmlList = xml.variable.(@type==classS);
a.push(xmlList);
if(mc1.numChildren>0){
for(i=0;i<mc1.numChildren;i++){
dobj = mc1.getChildAt(i);
if(dobj is MovieClip){
findF(MovieClip(dobj));
}
}
}
}
if(mc.numChildren>0){
for(i=0;i<mc.numChildren;i++){
dobj = mc.getChildAt(i);
if(dobj is MovieClip){
findF(MovieClip(dobj));
}
}
}
return a;
}
var a:Array = findObjectF(MovieClip(yourloader.content),"flash.media::Sound"); // this is the only line for you to edit. change yourloader to your loader reference (after loading is complete)
// the a[i].@name are your sound references.
p.s. please mark helpful/correct responses.
North America
Europe, Middle East and Africa
Asia Pacific