?
Solved

Is there an event listener in AS3 for when a sound file has finished playing?

Posted on 2009-06-30
1
Medium Priority
?
855 Views
Last Modified: 2013-11-11
Hi, I'm making a slow and painful transition from AS2 to AS3, and moreover I've never done much work with sound.  In any case I have a project where sound files will be loaded into the movie and played.  After certain files are finished playing, I want to control some movies or remove them all together from the stage.  All of this isn't a problem, except I haven't found an event listener for when a sound file finishes playing.  I have seen the "complete" event in the livedocs, but this appears to be when the file finishes loading -- not necessarily done playing.  Do I have to start timers or something?  Thanks in advance for help.  
0
Comment
Question by:Xerc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 2000 total points
ID: 24757705
There is, try the following:

<code>

-V
var mySoundChannel:SoundChannel = new SoundChannel();
var mySound:Sound = new Sound();
 
mySound.load(new URLRequest("some_file.mp3"));
mySoundChannel = mySound.play();
mySoundChannel.addEventListener(Event.SOUND_COMPLETE, soundComplete);
 
function soundComplete(event:Event):void {
  trace("done!");
}

Open in new window

0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question