The point is: How to stop the music in the other class.
Currently I have the three classes named: MainSound, Main, ContentPortfolio.
MainSound.as contains
Code:
package source.actionscript {
trace("Opening MainSound.as");
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
public class MainSound extends MovieClip {
public var _Sound:Sound;
public var _SoundChannel:SoundChannel;
public var isPlaying:Boolean;
public function MainSound() {
}
}
}
The Main starts music
Code:
public function playSound():void {
if(!_MainSound.isPlaying) {
trace("... Play sound ...");
with(_MainSound) {
_SoundChannel = _Sound.play();
isPlaying = true;
_SoundChannel.addEventListener(Event.SOUND_COMPLETE, _SoundChannel_SOUND_COMPLETE);
}
} else
if(_MainSound.isPlaying) {
trace("... Stop sound ...");
with(_MainSound) {
_SoundChannel.stop();
isPlaying = false;
}
}
}
And finally ContentPortfolio class where I need to stop the music, but when I add the MainSound class to portfolio class to stop the music, I creating new sound channel so thats make two different channels, so I cant stop first one from that class of portfolio.
What should I do?