Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : How do I make it wait?


zorgon
5/10/2004 10:42:18 PM
I have a keyframe at the END of a scene (scene 1) with a "go to and play"
action that jumps to another scene (scene 2).

Problem: The audio from scene 2 starts playing before scene one is finished
playing.

Is there anyway to require that scene one is finished playing before the "go
to and play" keyframe fires?

Thanks,

Gary
Shan-Dysigns
5/10/2004 10:52:33 PM
zorgon
5/10/2004 11:11:43 PM
The audio track is just on a layer in the timeline.

What is loadsound, and how would I use it to do what you describe?

zorgon
5/10/2004 11:17:16 PM
Also,

I found this for LoadSound: mySound.loadSound(" url ", isStreaming )

Just so you know, I'm building an .exe file, not a website or online application.

Shan-Dysigns
5/11/2004 6:17:27 AM
If you are making an .exe file, then you can just use the attachSound(); code.
You will first have to set a linkage identifier name to your sounds. In the
library where your sounds are, right-click on a sound file, then choose
linkage, export for action script and in first frame, and give it a name like
song1, song2, etc for each song/sound file.

This is a frame action placed on frame 1 of scene 1:

mysong = new Sound();
mysong.attachSound("song1");
mysong.start();
mysong.onSoundComplete = function() {
gotoAndPlay("whatever frame label name");
};


Make sure that scene 2 has a frame label on the frame where you want it to
start playing. On the last frame of scene 1, simply place a stop(); script. It
will wait here until song1 has completed playing and then will move forward to
whatever frame label you specified. Now if for example your song1 was to finish
BEFORE it reached the last frame of scene 1, then you are stuck because it's
just stopped. So you also need to add to that stop(): script to check if song1
was already finished, and if so to go ahead to the next frame label. So now the
above code becomes:

mysong = new Sound();
mysong.attachSound("song1");
mysong.start();
mysongstatus="isplaying";
mysong.onSoundComplete = function() {
mysongstatus="notplaying";
gotoAndPlay("whatever frame label name");
};

Then change the stop(); script frame action to:

if (mysongstatus == "isplaying") {
stop();
} else {
gotoAndPlay("whatever frame label name");
}

That should do it...
AddThis Social Bookmark Button