ActionScript 3 FLVPlayBack VideoEvent

3.1k Views Asked by At

How do you add an event listener when a FLVPlayback starts? Something like below:

my_player.addEventListener(VideoEvent.COMPLETE, completePlay);
my_player.addEventListener(VideoEvent.START, startPlay);

function completePlay(e:VideoEvent):void {
my_player.seek(0);
lastFrame.addChild(lastImage);

}

function startPlay(e:VideoEvent):void {

lastFrame.removeChildAt(0);

}

What I am trying to do is load a still image when the movie completes but when the user starts the video over I want to remove the still image if it is present.

1

There are 1 best solutions below

0
On BEST ANSWER

Your VideoEvent.COMPLETE event should be sufficient for knowing when it ends.

For the whole starting thing I would recommend the following:

my_player.addEventListener(VideoEvent.STATE_CHANGE, stateChanged);

function stateChanged( e:VideoEvent) : void {
    if ( e.state == VideoState.PLAYING ) {
           lastFrame.removeChildAt(0);
    }
}

//Additional states that may be useful:

VideoState.PAUSED_STATE_ENTERED
VideoState.PLAYING_STATE_ENTERED