Flash 可点击MC功能-AS2

Flash 可点击MC功能-AS2,flash,function,actionscript-2,movieclip,clickable,Flash,Function,Actionscript 2,Movieclip,Clickable,我需要一些帮助来解决这个问题。我在一个小游戏中有一些物体,我想根据它们的动画插图将它们击落 这个功能运行得很好: coke2.onPress = function () { if (coke2.shootable && shoot){ snimek = "anim" + Math.ceil((Math.random()*3)); coke2.gotoAndPlay(snimek); plusScore(100);

我需要一些帮助来解决这个问题。我在一个小游戏中有一些物体,我想根据它们的动画插图将它们击落

这个功能运行得很好:

coke2.onPress = function () {
    if (coke2.shootable && shoot){
        snimek = "anim" + Math.ceil((Math.random()*3));
        coke2.gotoAndPlay(snimek);
        plusScore(100);
        coke2.shootable = false;
    }
}
但是,当我有多个对象时,它不是有效的。我原以为下面的功能会很好地工作,但当我点击按钮时,什么也不会发生

function canClicked(can){
    if (can.shootable && shoot){
        snimek = "anim" + Math.ceil((Math.random()*3));
        can.gotoAndPlay(snimek);
        plusScore(100);
        can.shootable = false;
    }
}

coke.onPress = canClicked(this);
附言:不要介意函数里面的东西。那里没有问题


提前谢谢。

我自己解决了这个问题,将它插入到其他函数中,但我仍然不知道为什么我的想法不起作用

coke.onPress = function(){
    canClicked(this);
}