Highlighted

Music buttons - clicking on another music button will stop the music from the one you pressed before

New Here ,
Sep 21, 2019

Copy link to clipboard

Copied

I have a few buttons that if clicked with mouse it will play music, I'm trying to get to where if I play another music button, it will stop the previous music. And if I play another music button it will stop the previous music, etc. If there's a ActionScript code for this, let me know

TOPICS
ActionScript

Views

64

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Music buttons - clicking on another music button will stop the music from the one you pressed before

New Here ,
Sep 21, 2019

Copy link to clipboard

Copied

I have a few buttons that if clicked with mouse it will play music, I'm trying to get to where if I play another music button, it will stop the previous music. And if I play another music button it will stop the previous music, etc. If there's a ActionScript code for this, let me know

TOPICS
ActionScript

Views

65

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 21, 2019 0
kglad LATEST
Adobe Community Professional ,
Sep 22, 2019

Copy link to clipboard

Copied

you can always use SoundMixer.stopAllSounds() to stop all currently playing sounds, though it's often better to use a variable to reference the last played soundchannel and stop it explicitly when playing a new sound.  eg,

 

var currentSoundChannel;

 

function button1F(e:MouseEvent):void{

stopCurrentSoundF();

var s1:Sound1 = new Sound1();

currentSoundChannel = s1.play();

}

function button2F(e:MouseEvent):void{

stopCurrentSoundF();

var s2:Sound2 = new Sound2();

currentSoundChannel = s2.play();

}

etc...

 

function stopCurrentSoundF():void{

if(currentSoundChannel){

currentSoundChannel.stop();

}

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 22, 2019 0