AS3闪烁动态附加动画片段名称到goto功能

时间:2011-08-16 07:56:56

标签: actionscript-3 variables types

我有一个用于触摸屏界面的虚拟屏幕键盘。 我通过调用event.currentTarget.name来获取密钥的名称(Q,W,E等) 现在每个按钮都是一个带有小动画的影片剪辑,我需要知道 哪个键被按下所以它可以调用相关的movieclip .. 以下是代码:

function keyPressed(event:MouseEvent):void {

    var butID:String = event.currentTarget.name;
    trace("clicked " + butID);

 //////////////ERROR BELOW///////////

    Q.gotoAndPlay(2); <-------- Q is the name of the movieclip. It has to be something like butID.gotoAndPlay(2); but it doesn't work. I'm not sure of the type of the variable either...Can any one help?

/////////////////////////////
//Below I append the letter to a text box
    if(event.currentTarget.name == "SPACE")
    {
        addText(" ");
    }
    else
    {
        addText(event.currentTarget.name);
    }
}

提前致谢, Luben

1 个答案:

答案 0 :(得分:2)

您是否尝试过event.currentTarget.gotoAndPlay(2);

相关问题