VideoEvent.READY problem

I’m creating a basic gallery that is able to display images and movies. The content information is taken from an XML file, and the content is displayed using the Loader class in the case of images and a dynamically-added instance of the FLVPlayback component in the case of the movies. However, I have a problem with the VideoEvent.READY event, which I’m attempting to use to show the FLVPlayback component only when the video content is ready to play.

After defining

var myVideo:FLVPlayback = new FLVPlayback();

I’m using the following process to display video content:



function doVideo():void {

    myVideo.source = "content/"+xmlInfo[currentFrame-1];
    myVideo.x = (stageW/2)-(myVideo.width/2);
    myVideo.y = (stageH/2)-(myVideo.height/2);
    myVideo.addEventListener(VideoEvent.READY, addVideoToDisplay);

}

function addVideoToDisplay(e:VideoEvent):void {

    trace("addVideoToDisplay");
    myVideo.alpha = 0;
    addChild(myVideo);
    myVideo.seek(0);
    TweenMax.to(myVideo, 1, {alpha:1, ease:Linear.easeNone});

}

function removeVideo():void {

    myVideo.stop();
    TweenMax.to(myVideo, 1, {alpha:0, ease:Linear.easeNone, onComplete:removeVideoFromDisplay});

}

function removeVideoFromDisplay():void {
    removeChild(myVideo);
} 


This seems to work fine the first time my ‘next’ button calls doVideo and the gallery loads a video - the source is defined, the load method is triggered and the VideoEvent.READY event calls addVideoToDisplay when the video is ready to play. The problem arises when the user goes on to another slide, then back to the video content; or on to the next occurrence of video content - the source flv does not appear to load at all, as the screen remains blank. ‘addVideoToDisplay’ is not being traced, so the addVideoToDisplay function isn’t being called. My presumption is that the FLVPlayback component is till marked as ‘ready’, even though it’s been removed from the display stack and new content has been loaded. Is this the cause of the problem? Or is it something I’ve missed?

‘removeVideo’, I should add, is triggered when the user clicks ‘prev’ or ‘next’ buttons to navigate to another slide.

As always, apologies if the code is not clear or deficient in any other way. All suggestions on improving the overall functionality are gratefully accepted!