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
}

4 Responses to “Detect when Flash Video Reaches End of Playback (AS3)”

  1. Sell Online Says:

    good points thanks for sharing.

  2. jayesh Says:

    hello it is nice article….

  3. Andreas Says:

    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!!!

  4. Jon Says:

    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)

Leave a Reply

This entry was posted on Friday, October 9th, 2009 at 7:21 pm and is filed under Flash Design & Development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.