Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS3动态地将movieclip名称附加到goto函数_Actionscript 3_Variables_Types - Fatal编程技术网

Actionscript 3 AS3动态地将movieclip名称附加到goto函数

Actionscript 3 AS3动态地将movieclip名称附加到goto函数,actionscript-3,variables,types,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); /////

我有一个虚拟的触摸屏键盘。 我通过调用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);
    }
}
按下功能键(事件:MouseEvent):无效{ var butID:String=event.currentTarget.name; 跟踪(“单击”+butID); //////////////下面的错误///////////
问:gotoAndPlay(2);你试过
事件.currentTarget.gotoAndPlay(2);

谢谢你!!我试过event.currentTarget.name.gotoAndPlay(2);,但没用。