views:

25

answers:

1
stop();

var nc:NetConnection = new NetConnection(); 
nc.connect(null); 
var ns:NetStream = new NetStream(nc); 
var listener:Object = new Object(); 
listener.onMetaData = function(md:Object):void{}; 

listener.onPlayStatus = function(info : Object) : void {
    trace("onPlayStatus:" +info.code + " " + info.duration);
    if (info.code == "NetStream.Play.Complete") {
        var endLoader:Loader = new Loader();
  endLoader.load(new URLRequest("secondmovie.swf"));
  addChild(endLoader);
  initializeVideo();

    }
};
ns.client = listener; 

vid1.attachNetStream(ns); 


var movietoplay:String = "firstmovie.flv"; 
ns.play(movietoplay);

function initializeVideo():void {
 ns.close();     
}

Can anyone help me load the swf once the flv is done playing? I think I'm just not loading the swf right because the flv plays correctly.

A: 

The swf should already be loaded when the video complete event fires, this way it would start playing instantly as opposed to waiting for it to load , then play. simply preload the swf and when the video finishes , add the swf to the display list.

at the moment you wait for the video to complete to start loading , not playing the swf , meaning that there will be a delay proportional to the swf size , before it starts playing

stop();

//start the swf loading process
var endLoader:Loader = new Loader();
endLoader.load(new URLRequest("secondmovie.swf"));

//start the video
var nc:NetConnection = new NetConnection(); 
nc.connect(null); 
var ns:NetStream = new NetStream(nc); 
var listener:Object = new Object(); 

listener.onMetaData = function(md:Object):void{}; 
listener.onPlayStatus = function(info : Object) : void {
    trace("onPlayStatus:" +info.code + " " + info.duration);

    if (info.code == "NetStream.Play.Complete") 
    {
        //unless the swf size is really big or the video really short , 
        //the swf should be loaded
        //add it it should start playing straight away.
        addChild(endLoader);
        initializeVideo();
    }
};
ns.client = listener; 

vid1.attachNetStream(ns); 


var movietoplay:String = "firstmovie.flv"; 
ns.play(movietoplay);

function initializeVideo():void {
 ns.close();     
}
PatrickS
thats what I thought it may be doing. What I want to happen is after a FLV is done playing, a SWF opens...all I have to open a swf after FLV is a timer, and that doesnt work sometimes. Someone here gave me the code for the listener, to listen when it gets done dynamically, then open a SWF..??
mike
that actually makes complete sense now, thank you thank you thank you!!!
mike