Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Monitor end of music to call get URL.

Status
Not open for further replies.

tommytx

Programmer
Nov 27, 2002
28
US
I need to write script to call another flash external movie with getURL at the instant the music stops. The initial flash program gives a show on stage with curtains opening and some acts on the stage, and after the show, the curtans close and the stage remains in tact with no futher action on screen until the end of the music. Howver the music continues about 45 seconds after all is done. I need to call another url as soon as the music is done. Is there a way I can begin to monitor the music to call get url when the music is done. This would then load another url.
I can't just time it, and load the next url in 45 seconds as some shows have music longer than others.
I hope there is a loop I can set up to keep checking the music status like we check the loading frame status to see when it is done.
Any ideas would be greatly appreciated.
 
Is the music a soundObject?
If not is it's Sync set to "stream" or "event"?
 
Couple of ways to do this:

1. Have the sound published as it's own .swf - basically a movie with no visuals just the event sound on the timeline. Bring it into your main movie with loadMovie and have the getURL or a function call to your main movie on the last frame which performs the action you need. This has the advantage of requiring little programming and the .swf will be very small because Flash sound compression is so good.

2. If you're using a sound from a Sound() object you can access it's onSoundComplete() method:

Code:
mySound.onSoundComplete=function(){
getURL('myURL.html',_blank);
}
 
Which was not a requirement of the original question. It will however solve the problem as stated. Any sound on a timeline is, by definition, an event - whether the sound itself is set to 'event' or 'stream' is irrelevant in this instance as we're working with a prepublished .swf file which streams by default.
 
Yes my bad in a way! But somewhat your's also!

My only point was that if the sound's sync is set to "event", in your "streaming external" sound movie and is, as it would usually be with an "event" sound, only set on one single frame, how would you determine when the sound had finished playing and where would you put the getURL or function call on frame 2?
You forgot to mention that you should lay as many frames on the timeline, as it usually done with a "stream" sound (otherwise you wouldn't really hear that "stream" sound), as needed to "display" and "hear" the whole sound, so that at the end of the sound's modulations, is where you would need to add the getURL or the function call.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top