Copy link to clipboard
Copied
A rudimentary question from a neophyte. I just want to play some music as part of my swf file and at the end of the song, automatically retrieve a web page. I'm finding a lot of answers for very complex questions, but nothing quite so basic. Any suggestions you might offer me would be greatly appreciated. Thank you. Mark
1 Correct answer
my fault. the listener has to be added after the soundchannel is defined:
var m:Music = new Music(); var sc:SoundChannel = m.play(); sc.addEventListener(Event.SOUND_COMPLETE,f); function f(e:Event){ navigateToURL(new URLRequest("http://www.adobe.com")); }
Copy link to clipboard
Copied
import your sound into the library, right click on it, tick export for actionscript and assign it a class name, say Music. you can then use:
var sc:SoundChannel = new SoundChannel();
sc.addEventListener(Event.SOUND_COMPLETE,f);
var m:Music = new Musc();
sc = m.play();
function f(e:Event){
navigateToURL(new URLRequest("http://www.adobe.com"));
}
Copy link to clipboard
Copied
Was able to play the Music file in the swf file just fine but at the end of the music file's completion the URL does not activate in a browser. Do you have any suggestions?
Copy link to clipboard
Copied
are you using the code i gave?
Copy link to clipboard
Copied
Yes, used your code. The music file plays in the swf file but the browser isn't activated to retrieve the URL when it finishes.
When I remove all the previous lines and test just this part (below) the swf file does in fact retrieve the URL:
{
navigateToURL(new URLRequest("http://www.adobe.com"));
}
When I add the previous lines of the code back I have the same problem.
I'm not using any other code than what you gave me in the actionscript panel.
I corrected for the "Musc" typo in the original code, so it's not that.
Copy link to clipboard
Copied
my fault. the listener has to be added after the soundchannel is defined:
var m:Music = new Music(); var sc:SoundChannel = m.play(); sc.addEventListener(Event.SOUND_COMPLETE,f); function f(e:Event){ navigateToURL(new URLRequest("http://www.adobe.com")); }
Copy link to clipboard
Copied
Works fine. Thanks a million! Much, much appreciated.
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
I'm wondering if I might impose on you one more time, or if someone else might have a suggestion. Relative to this same operation, instead of navigating to a URL at the end of a video, I'd like to play an FLV file in the same player instance after the first video has ended. Can you suggest a modification to the above code to accomplish this? Or perhaps another approach altogether? Thank you. Mark
Copy link to clipboard
Copied
in f() instead of using navigateToURL(), use the source method of your flvplayback instance to point to the 2nd video. if autoplay is true, the 2nd video will start without the need to execute the play() method.
p.s. be careful. unless you want an endless loop of the this 2nd video, you'll need to use a variable to determine whether the 2nd video has completed (and you don't want to re-start the 2nd) or the 1st video has completed (and you want the 2nd to start).
Copy link to clipboard
Copied
Thanks, again. Works terrifically!
Copy link to clipboard
Copied
you're welcome.

