A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: turn off sound only - how?

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    85

    Question turn off sound only - how?

    Hello,

    I have this problem:

    How do you turn off the sound in a game only? I ask because I have two buttons in my settings: turn music on/off and sound on/off. turning music on and off is really easy because it uses a specific sound channel. But How do you turn off the volume the sound only (e.g. music is still playing but not the sound of the game)?

    When I mute the sound via SoundMixer.soundtransform you can't hear anything so that's not what I wanted to have. In my game all sounds are thrown into an array. My first idea was that I go through all sounds listed in the array and turn off the volume but that's not working. Please - can anyone help? Thank you very much.

    Code:
    //not working
    
    private var sounds:Array;
    private var soundChannels:Array = [];
    private var muteSoundTransform:SoundTransform = new SoundTransform();
    
    public function muteSoundOnly():void {
    
    muteSoundTransform.volume = 0;
    			
    var soundLength:int = soundChannels.length - 1;
    for (var soundCtr:int = soundLength; soundCtr >= 0; soundCtr--)
    {
    				
    	soundChannels[soundCtr].soundTransform = muteSoundTransform;
    				
    	}
    			
    }

  2. #2
    Member
    Join Date
    Jun 2011
    Posts
    85
    Ok. I got the problem solved. Actually I just forgot to insert a public variable for my sound events so I can control the volume. I'm such a dumbass!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center