A sound question

i am working on finishing up my website, and i’m having a little problem with the sound. it’s a multi-scene movie, and with the sound controls and settings i have, the stop and start buttons are a little screwy. if i stop the sound in one scene, and then switch to another and want to start the sound up again, i have to push stop before i can push play. i understand that the code says the play button is disabled at the start of every scene, but i’m wondering if there is a way i can write an if statement that can detect whether or not the sound is already playing and enable or disable the buttons based on that. can anybody help? the website is located here , and this is the actionscript for the sound action frame:

[AS]bgSound = new Sound(this);
bgSound.attachSound(“sound1”);
playB.enabled=false;
stopB.onRelease = function() {
bgSound.stop();
playB.enabled=true;
stopB.enabled=false;
};
playB.onRelease = function() {
bgSound.start(0, 99);
playB.enabled=false;
stopB.enabled=true;
};
stop();[/AS]

If you want to use an if statement, you can try using the “position” property. I forget the exact syntax cuz flash isn’t in front of me, but I think it’s like

bgSound.position

no parenthesis i believe.

In any event, when the sound is stopped, the position should be zero, so you can do your if statements against that, i.e.

if(bgSound.position == 0){
myButton.enabled = true;
}else{
myButton.enabled = false;
}

another option is perhaps that your sound object doesn’t EXIST yet when you transfer between scenes, depending on how you’ve set up your flash movie. If so, you can do an if check against whether or not the sound object exists, i.e.

if(bgSound){
if it exists, do this;
}else{
do this;
}

Hopefully my syntax is alright, and good luck.

–EP

i tried the position statement, which worked for not having to push stop to get the sound to start again. it didn’t carry out the else statement though, so i’m not totally sure if it worked out how i wanted it to. this is how i did it:

[AS]if(bgSound.position == 0){
playB.enabled = true;
stopB.enabled = false;
}else{
playB.enabled = false;
stopB.enabled = true;
}[/AS]

i linked the sound and loaded it into an empty frame via the advice of another help forum… thank you for the help, i will keep messing around with it and hopefully something will work out! :slight_smile: