design. business. life.

Information

This article was written on 09 Oct 2009, and is filled under Flash.

Current post is tagged

, ,

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 Comments

  1. Andreas
    December 4, 2009

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

  2. Jon
    March 9, 2010

    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)

  3. Nick
    January 31, 2011

    Thanks so much. You saved me some big headaches.

  4. My brother suggested I would possibly like this website. He was once entirely right. This publish truly made my day. You can not imagine just how so much time I had spent for this information! Thanks!

Leave a Reply