0

我正在制作横幅,在横幅中我有一个电影剪辑,该剪辑从动作脚本中的库链接并调用“mcHelmet”。我需要它出现在 x 轴上的随机位置,并且它从上到下移动(如雨)。

问题是,在 25 秒后,我希望它会转到另一个帧 (10),并且“mcHelmet”会消失。一切正常,除了“mcHelmet”无论我使用什么代码都不会消失;删除,r​​emoceMovieClip,使用函数没有任何作用。

我需要帮助。

这是我使用的代码:

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

}
}   
4

1 回答 1

1

要删除您放在舞台上的最后一个 mc,我建议使用变量或数组;数组会足够有效:

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

现在您的 MovieClips 将存储在 array() 中;

             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 中删除对我有用的最后一项。

于 2013-05-08T16:26:40.043 回答