Solved

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

Posted on 2009-06-30
1
852 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
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): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

776 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