Skip navigation
Nhide13
Currently Being Moderated

Loaded SWF sound handling - issue

Aug 31, 2012 2:29 AM

Tags: #sound_issue

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!      

 
Replies
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    Aug 31, 2012 8:28 AM   in reply to Nhide13

    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.

     
    |
    Mark as:
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    Aug 31, 2012 9:27 AM   in reply to Nhide13

    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?

     
    |
    Mark as:
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 3, 2012 9:57 AM   in reply to Nhide13

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points