2013-05-08 90 views
0

我正在做的旗幟和橫幅我有一個電影剪輯,從庫中的動作腳本鏈接,並呼籲「mcHelmet」。我需要它出現在x軸上的一個隨機位置,並從上到下(如下雨)。的Flash ActionScript 2的刪除鏈接的MovieClip

問題是,在25秒後,我希望它會轉到另一幀(10) ,並且「mcHelmet」將消失。 所有的工作正常,除了「mcHelmet」拒絕消失無論我使用什麼代碼; 刪除,remoceMovieClip,使用函數無效。

我需要幫助。

這是我使用的代碼:

onEnterFrame = function(){ 
url_btn.onRollOver = btn.onDragOver = function(){ 
     startDrag(mc_girl,true,10,186,270,131); 
     mc_girl._x = _xmouse; 

     if(_xmouse < mc_girl.width /2){ 
      mc_girl._x = 0; 
     } 

     if(_xmouse > stage.width - mc_girl.width /2){ 
      mc_girl._x =Stage.width - mc_girl._width; 
     } 
     if(mc_girl._x <= 0){ 
      mc_girl._x += mainSpeed; 
     } 
     if(mc_girl._x >= Stage.width - mc_girl._width){ 
      mc_girl._x -= mainSpeed; 
     } 

     StopTimer(); 
    } 

//this function will run every frame (needed for moving the character 
HelmetTime++; 
//incrementing time for enemy 
if (HelmetTime == HelmetLimit) 
{ 
    //if enough time has elapsed 
    _root.attachMovie('mcHelmet','en' + HelmetTotal,_root.getNextHighestDepth()); 
    //then add the enemy 
    //setting it's coordinates 
    _root['en' + HelmetTotal]._x = int(Math.random() * Stage.width); 
    //randomly within the boundaries 
    _root['en' + HelmetTotal]._y = -50; 
    //sets this offstage at first 
    _root['en' + HelmetTotal].onEnterFrame = function() 
    { 
     //then give it some functions 
     this._y += 4; 
    } 
    HelmetTime = 0; 
    //reset the time 
    HelmetTotal++; 
    //add 1 more to the amount of enemies total 

} 
} 
+0

我想在AS2你只能刪除您添加最新的MC,我認爲這是所謂像detachMovie或類似的東西。如果您搜索Flash API Actionscript 2,您應該找到參考。 – 2013-05-08 15:53:27

回答

1

要刪除您haved把舞臺上的最後一次MC,我建議一個變量或數組,數組將是足夠有效的:

  var myMovieclips_holder:Array = new Array(); 
      //everytime you add a mc to stage ,also add it here 
      addchild(myMovieClip) 
      myMovieclips.push(myMovieClip); 

現在你的動畫片段將被存儲在數組()中;

   trace(myMovieclips_holder) // array[0] Movie clip , array[1] etc 

允許刪除最後一個片段:

   var i = myMovieclips_holder.length - 1 
       myMovieclips_holder[i].parent.removeChild(myMovieclips_holder[i]); 

這應該從陣列中刪除最後一個項目nomatter,你有嵌套它 爲我工作。

+0

謝謝。我會試試看,並讓你知道 問題,我不是那麼專業地控制AS2,所以我希望我會做到這一點。 – 2013-05-08 19:31:31