Flash as2添加到变量并删除影片剪辑

时间:2012-03-23 13:04:52

标签: flash actionscript-2 movie clip

我一直试图解决这个问题几个小时,无论我做什么,我都无法理解。我收集所有硬币后,我的游戏中的门户网站将被解锁。门户网站已被锁定,但当我查看硬币时,它既不会添加变量,也不会通过实例名称coin1 coin2和硬币3删除影片剪辑。有人可以帮助我吗?

如果删除影片剪辑不需要_root我已经尝试过没有它我知道这不是问题。

var openportal = 0;
function moveStuff() {
      //-Very long code that is working.    
}


if (ball_mc.hitTest(coin1._x, coin1._y)) {
    removeMovieClip(_root.coin1);
                var openportal = openportal + 1;
        }
        if (ball_mc.hitTest(coin2._x, coin2._y)) {
            removeMovieClip(_root.coin2);
                var openportal = openportal + 1;
        }
        if (ball_mc.hitTest(coin3._x, coin3._y)) {
            removeMovieClip(_root.coin3);
                var openportal = openportal + 1;
        }

        if (openportal >= 3){
           if (goal1_mc.hitTest(ball_mc._x, ball_mc._y)) {
                gotoAndStop(2);
           }
        }
ball_mc.onEnterFrame = moveStuff;

1 个答案:

答案 0 :(得分:0)

试试这个:

var openportal = 0;
function moveStuff() {
      //-Very long code that is working.    
}

        if (ball_mc.hitTest(coin1._x, coin1._y)) {
            _root.removeMovieClip(coin1);
            openportal++;
        }
        if (ball_mc.hitTest(coin2._x, coin2._y)) {
            _root.removeMovieClip(coin2);
            openportal++;
        }
        if (ball_mc.hitTest(coin3._x, coin3._y)) {
            _root.removeMovieClip(coin3);
             openportal++;
        }

        if (openportal >= 3){
           if (goal1_mc.hitTest(ball_mc._x, ball_mc._y)) {
                gotoAndStop(2);
           }
        }
ball_mc.onEnterFrame = moveStuff;