2012-11-09 48 views
0

hai我想在我的動作腳本項目中播放兩個swf文件。在這兩個文件中,一個swf文件在系統前面的檢測面上工作。其他swf播放flv文件。當如果不是播放器必須播放flv文件,則必須彎曲播放器。如何在as3中播放兩個swf文件

我知道如何加載swf文件,但我無法處理啓動和停止播放器的功能。

的代碼片段展示了我如何可以加載外部SWF文件。而我會解釋意見

public function videos(view:Sprite) 
    { 
     this.box = view;//IT GETS Sprite object from other class because of    need to display the player also. 
     request = new URLRequest("Untitled-1.swf"); 
     currentSWF=new MovieClip(); 


     loader= new Loader(); 
     loader.load(request); 

     box.addChild(loader); 
     currentSWF = MovieClip(loader.content); 
     loader.addEventListener(Event.COMPLETE,loadComplete); 
     //addChild(loader); 
     currentSWF.gotoAndPlay(1);//when i put this line of code in comments it plays the external swf also. 


    } 

我希望你明白我的疑問。可任何一個解釋如何處理我的事情的每一行代碼.i新手這個動作script.please幫助我

回答

0

加載文件自動播放,除非你明確告訴他們不要。你必須聽Event.INIT事件,並停止影片有:

loader.AddEventListener(Event.INIT, initLoader); 

function initLoader (event:Event) 
{ 
    MovieClip(event.currentTarget.content).stop(); 
} 

它連接到舞臺前,這將停止播放電影,並開始播放前,所以它不會做除非你再次啓動它。

注意,你不應該INITCOMPLETE事件之前以任何方式訪問loader.content,因爲它很可能是內容不裝呢。因此,您應該將所有操作行爲放入COMPLETE事件中:

box.addChild(loader); 
loader.addEventListener(Event.COMPLETE, loadComplete); 

function loadComplete (event:Event) 
{ 
    // Now it’s safe to access the `content` member: 
    currentSWF = MovieClip(loader.content); 

    // Of course this one would play the movie again, so you probably want 
    // to call that later on a button click or something. 
    currentSWF.gotoAndPlay(1); 
}