2010-09-11 13 views
-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();  
} 

任何人都可以帮我加载swf一旦flv完成播放?我想我只是没有加载swf,因为flv播放正确。如何使用AS3中的事件处理程序加载swf文件?

回答

2

当视频完成事件触发时,swf应该已经加载,这样它就会立即开始播放,而不是等待它加载,然后播放。只需预先加载swf,当视频结束时,将swf添加到显示列表中。

你等待视频完成开始加载,而不是播放SWF,这意味着将有到SWF的大小成比例的延迟,它开始播放

 
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();  
} 
+0

前的那一刻,多数民众赞成我的想法它可能在做。我想要发生的事情是在FLV播放完毕后,SWF打开......所有我必须在FLV启动后才能打开swf,这有时并不奏效。这里有人给我听代码的代码,听它什么时候动态完成,然后打开一个SWF .. ?? – mike 2010-09-11 13:25:03

+0

现在实际上完全有意义了,谢谢谢谢谢谢! – mike 2010-09-11 15:14:46

+0

@mike:如果PatrickS正确解决了您的问题,请考虑将他的回复标记为答案。你可以通过点击帖子左边的勾号来做到这一点。 – 341008 2011-01-12 06:06:00

相关问题