Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simply play sound, then load webpage using AS3?

New Here ,
Apr 23, 2009 Apr 23, 2009

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

TOPICS
ActionScript
944
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 24, 2009 Apr 24, 2009

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"));
}
Translate
Community Expert ,
Apr 23, 2009 Apr 23, 2009

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"));

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 23, 2009 Apr 23, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 23, 2009 Apr 23, 2009

are you using the code i gave?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2009 Apr 24, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2009 Apr 24, 2009

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"));
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2009 Apr 24, 2009

Works fine. Thanks a million! Much, much appreciated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2009 Apr 24, 2009

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 25, 2009 Apr 25, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 25, 2009 Apr 25, 2009

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 25, 2009 Apr 25, 2009

Thanks, again. Works terrifically!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 25, 2009 Apr 25, 2009
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines