-
Sound problem
Hi, i am going through an issue that i cannot solve.
I have applied sound to my website in flash. I have different pages designed in different scenes. And sound control is present on each and every scene. I browsed through the net and found a tutorial which showed how to play background sound and keep it continuos throughout the navigation via different scenes. Inicially i had a problem where the sound restarted when i went to a new scene but now that problem is solved . My current problem is, when my site loads the music starts to play which is fine. Then when i press on the sound button to stop it . The action is to Start Sound and when i press it again It stops. But When i stop it and go to any other button and navigate to some other scene , the sound restarts.
My guess - The sound sequence needs to be Stop on the first click and Play on the second.
But i also want the sound to autostart when site loads. And i because i have different scenes i have applies a complicated action scrip from a tutorial.which goes as follows:-
On the first frame of sound layer i have this action script --->
_root.sound1 = new Sound(this);
_root.sound1.attachSound("sound1a");
On the last frame of the same layer of sound i have the following script --->
on(press) {
if (playing != 1) {
playing = 1
_root.sound1.start(0,999)
} else {
stopAllSounds();
playing = 0;
}
}
I am not a hardcore actionscript professional so i dont understand most of this. Though i would appreciate if someone could help me.
-
Registered User
hi,
This should be the idea.
Code for the first frame:
PHP Code:
// if the sound doesn't exist,
if (sound1 == undefined)
{
// create it
var sound1:Sound = new Sound (this);
sound1.attachSound ("sound1a");
// and start playing
sound1.start(0,999);
// define a variable which knows that the sound is playing
var isPlaying = true;
}
Code for the frame where the button is. Assuming the button has an instance name of my_btn.
PHP Code:
// when you click the button
my_btn.onRelease = function()
{
// if the sound is playing
if (isPlaying)
{
// stop it
sound1.stop();
}
else
{
// start it
sound1.start(0, 999);
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|