How to Use Flash MX Sound Objects

This document copyright © 2005, 2006 by Kenny Bellew of Cowfly.Com Design, kennybellew@hotmail.com
How to Use a Single Button both to Start and Stop a Sound Object Return to Index Do you want all FLA's used for this tutorial? Do you have a question?

I have been asked a few times how to use the same button to toggle the sound on and off. Here is the code for that:

on(release) {
if (_root.playing!=1) {
if (mySoundPosition==null) {
mySoundPosition=0;
}
_root.mySound.start(mySoundPosition,0);
_root.playing=1;
} else {
if (_root.playing==1) {
mySoundPosition=_root.mySound.position/1000;
_root.mySound.stop();
_root.playing=0;
}}
}

// Be sure to change "mySound" to the name of your sound object.

 

Previous Next
How to Start, Stop and Loop a Sound Object How to Control Independent Sound Objects Simultaneously
Return to Index Do you want all FLA's used for this tutorial? Do you have a question?

This document copyright © 2005, 2006 by Kenny Bellew of Cowfly.Com Design, kennybellew@hotmail.com