2011-04-18 86 views

回答

0
package 
{ 
    import flash.display.Loader; 
    import flash.display.MovieClip; 
    import flash.display.Sprite; 
    import flash.events.Event; 
    import flash.events.TimerEvent; 
    import flash.net.URLRequest; 
    import flash.utils.Timer; 
    import flash.utils.getTimer; 

    public class Test extends Sprite 
    { 

     private var _loader : Loader; 
     private var _loadedSWF : MovieClip; 
     private var _timer : Timer; 

     public function Test() 
     { 
      _loader = new Loader(); 
      _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete); 
      _loader.load(new URLRequest("OtherSWF.swf")); 

      _timer = new Timer(1000, 1); 
      _timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete); 
     } 

     private function onLoadComplete(event : Event) : void 
     { 
      trace("onLoadComplete: " + getTimer()); 

      // add to displaylist 
      _loadedSWF = event.currentTarget.content; 
      _loadedSWF.stop(); 
      _loadedSWF.visible = false; 
      addChild(_loadedSWF); 

      // start timer 
      _timer.start(); 
     } 

     private function onTimerComplete(event : TimerEvent) : void 
     { 
      trace("onTimerComplete: " + getTimer()); 

      _loadedSWF.visible = true; 
      _loadedSWF.play(); 
     } 
    } 
} 

http://kb2.adobe.com/cps/141/tn_14190.html

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/Timer.html

+0

,然後計時器之後將新的SWF開始? – 2011-04-18 05:32:27

+0

它取決於你在函數usin myOtherSWF.play()中做到這一點。 – Mattias 2011-04-18 05:35:17

+0

確保添加一個stop();在你的SWF中阻止它在負載上播放。 – Mattias 2011-04-18 05:41:09

相關問題