我试图通过按键从库中播放一个moveiclip,我已经链接了它,但它仍然不起作用(这只是代码的一部分,有事件侦听器和处理程序,角色移动正常)
stage.addEventListener(Event.ENTER_FRAME, Move);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPress);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUp);
var aP:Boolean = false;
var dP:Boolean = false;
//creating a new Character_right instance
var character_right:Character_right = new Character_right();
function Move(vet:KeyboardEvent)
{
if(aP)
{
char.x -= 5;
char.scaleX = -0.55;
}
if(dP)
{
char.x += 5;
char.scaleX = -0.55;
}
}
function keyPress(evt:KeyboardEvent)
{
switch(evt.keyCode)
{
case Keyboard.A:
{
aP = true;
break;
}
case Keyboard.D:
{
dP = true;
character_right.play();
break;
}
}
}
function keyUp(evt:KeyboardEvent)
{
switch(evt.keyCode)
{
case Keyboard.A:
{
aP = false;
break;
}
case Keyboard.D:
{
dP = false;
break;
}
}
}