0

我想问一下这个代码..

 if (objek.dropTarget.parent.name == "book")
            {
    if ((objek == alif) || (objek == ba)){  //yg perlu diganti
    //if (objek == objBenar){  //yg perlu diganti
                objek.x = objek.dropTarget.parent.x;
                objek.y = objek.dropTarget.parent.y + 50;
                objek.removeEventListener(MouseEvent.MOUSE_DOWN, down);
                objek.buttonMode = false;
                var _loc_2:Number;
                objek.scaleY = 0.4;
                objek.scaleX = _loc_2;
                objek.alpha = 0.6;
                score+=5;
                scorebox.text = "Score: " + score;
            }
            else {
            objek.x = objek.dropTarget.parent.x;
                objek.y = objek.dropTarget.parent.y + 50;
                objek.removeEventListener(MouseEvent.MOUSE_DOWN, down);
                objek.buttonMode = false;
                var _loc_2:Number;
                objek.scaleY = 0.4;
                objek.scaleX = _loc_2;
                objek.alpha = 0.6;
                score-=2;
                scorebox.text = "Score: " + score;}
            }

        }

我有movieclip alif、ba 和dal..这三个可以拖到名为“book”的movieclip 并且分数会改变。如果我将 alif 和 ba 电影剪辑拖到书上,分数会增加.. 如果我将 dal 电影剪辑拖到书上,分数会降低.. 如果我想制作一个数组的电影剪辑 alif 和 ba 怎么办?如何编写条件? ? 帮助 :(

4

1 回答 1

0

我不确定我是否理解,但是您是否想要一个包含 alif 和 ba 的数组,然后检查影片剪辑是否在该数组中?这就是你要这样做的方式:

var scoreIncreasers:Array = [alif, ba];
var isScoreIncreaser:Boolean = (scoreIncreasers.indexOf(objeck) !== -1);
if(isScoreIncreaser) {
    // Increase score
}

编辑:

根据您的评论,我认为这就是您想要的:

var objBener:Array = [alif, ba];
if(objBener.indexOf(objek) !== -1) {
    //yg perlu diganti
}
于 2013-01-25T17:35:53.523 回答