Question

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.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top