Solved

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

Posted on 2009-06-30
1
851 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
1 Comment
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now