Solved

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

759 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

25 Experts available now in Live!

Get 1:1 Help Now