Detect when Flash Video Reaches End of Playback (AS3)
Need to execute some action when your FLV reaches the end? Pretty simple:
import fl.video.VideoEvent;
wihsvid.addEventListener(VideoEvent.COMPLETE, RestartVid);
function RestartVid(evt:VideoEvent):void{
this.gotoAndStop(1);
}
//you need to import the VideoEvent (no idea why??)
import fl.video.VideoEvent;
//Add an EventListener – replace ‘myvideo’ with your video instance name and ‘VideoEndAction’ with the function you want to run.
myvideo.addEventListener(VideoEvent.COMPLETE, VideoEndAction);
function VideoEndAction(evt:VideoEvent):void{
//some action here
}
November 23rd, 2009 at 11:06 am
good points thanks for sharing.
November 28th, 2009 at 12:32 am
hello it is nice article….
December 4th, 2009 at 8:25 am
Didn’t know about the import videoEvent thing. Couldn’t figure out why my end action wasn’t working. Then I found this post. Thanx a lot!!!
March 9th, 2010 at 11:47 am
Well the line import fl.video.VideoEvent imports the VideoEvent class which handles the video related events READY, COMPLETE, CLOSE and so on.
If you don’t want to import VideoEvent class directly, you can always use just
import fl.video.* which imports all classes under fl.video. (FLVPlayback,SoundEvent etc)