Actionscript 3 AS3动态地将movieclip名称附加到goto函数
我有一个虚拟的触摸屏键盘。 我通过调用event.currentTarget.name来获取密钥的名称(Q、W、E等) 现在每个按钮都是一个带有小动画的电影剪辑,我需要知道 按下哪个键可以调用相关的movieclip。。 代码如下: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); /////
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);,但没用。