2013-05-08 84 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