2013-04-05 91 views
0
package 
{ 
    import flash.display.*; 

    public class documentclass extends MovieClip 
    { 
     public var playscreen:avoiderclass; 

     public function documentclass() 
     { 
      playscreen.addEventListener(playerEvent.DEAD, onplayerdeath); 
      playscreen.x = 0; 
      playscreen.y = 0; 
      playscreen = new avoiderclass(); 
      addChild(playscreen); 
     } 
     public function onplayerdeath(PlayerEvent:playerEvent):void 
     { 
      var Gameover:gameover = new gameover(); 
      Gameover.x = 0; 
      Gameover.y = 0; 
      addChild(Gameover); 

      playscreen = null; 
     } 
    } 

} 

好,它工作時,舞臺(這類)是拉玩家和敵人的影片剪輯到它的類。然後我添加了這個舞臺,併爲另一個播放屏幕... 我不知道爲什麼它不工作,但任何人都可以給我任何可能性,爲什麼它不會,沒有錯誤彈出... ...錯誤添加一個影片剪輯,在AS3中增加了更多的影片剪輯自

+0

什麼不對刪除播放屏幕?你還沒有真正解釋過什麼是錯的。如果沒有描述什麼是不工作和Avoiderclass代碼,我們無法真正幫助你。 – prototypical 2013-04-05 21:38:40

回答

0

你必須可變播放屏幕設置這樣一個新的avoiderclass對象:

 playscreen = new avoiderclass(); 

前做..

 playscreen.addEventListener(playerEvent.DEAD, onplayerdeath); 
     playscreen.x = 0; 
     playscreen.y = 0; 

請嘗試這種方式。

public class documentclass extends MovieClip { 
    public var playscreen:avoiderclass; 

    public function documentclass(){ 
     // construct the object first 
     playscreen = new avoiderclass(); 
     // then manipulate it. 
     playscreen.addEventListener(playerEvent.DEAD, onplayerdeath); 
     playscreen.x = 0; 
     playscreen.y = 0; 
     addChild(playscreen); 
    } 

在這裏,在功能不要忘記從顯示列表

public function onplayerdeath(PlayerEvent:playerEvent):void { 
     var Gameover:gameover = new gameover(); 
     Gameover.x = 0; 
     Gameover.y = 0; 
     addChild(Gameover); 
     // first remove the playscreen from display list 
     removeChild(playscreen); 
     // then set it to null, now really unreachable and eligible for gc 
     playscreen = null; 
    } 
    } 
} 
+0

花了我一分鐘來理解你的帖子,但是一旦我意識到你基本上是說「在放置playscreen = new avoiderclass()之前不要設置x和y的行......謝謝 – theHeretic 2013-04-05 22:19:54

+0

好吧,試着用更多可以理解的語言,而且你很好。 – Ihsan 2013-04-06 10:01:24