Actionscript 3 没有键盘输入AS3
所以我试图从用户那里获得键盘输入来移动一个字符。它在我使用的另一个程序中工作,我复制粘贴,但在这个程序中不工作。它给了我Actionscript 3 没有键盘输入AS3,actionscript-3,flash,keyboard-input,Actionscript 3,Flash,Keyboard Input,所以我试图从用户那里获得键盘输入来移动一个字符。它在我使用的另一个程序中工作,我复制粘贴,但在这个程序中不工作。它给了我第87行第38列1119:通过静态类型类的引用访问可能未定义的属性EVENT\u FRAME。我似乎不知道问题出在哪里 这是我按下开始按钮时使用的按钮单击功能 public function buttonClick(ev:MouseEvent):void { createGameScreen(); this.mcLink.goto
第87行第38列1119:通过静态类型类的引用访问可能未定义的属性EVENT\u FRAME。
我似乎不知道问题出在哪里
这是我按下开始按钮时使用的按钮单击功能
public function buttonClick(ev:MouseEvent):void
{
createGameScreen();
this.mcLink.gotoAndPlay("Idle");
this.mcLink.x=50;
this.mcLink.y=200;
this.mcLink.scaleX=this.mcLink.scaleY=3;
this.stage.addEventListener(Event.EVENT_FRAME, this.enterFrameHandler, false, 0, true);
}
这是键盘输入的事件处理程序函数
public function enterFrameHandler($e:Event):void
{
if (this.mcLink)
{
if (KeyboardManager.instance.isKeyDown(KeyCode.DOWN))
{
if (this.mcLink.y + this.mcLink.height > this.stage.stageHeight || this.mcLink.y - this.mcLink.height <= 0)
{
this.mcLink.y += -15;
mcLink.gotoAndPlay("Idle");
return;
}
this.mcLink.y += _nHeroMovementSpeed;
mcLink.gotoAndPlay("Down");
}
else if (KeyboardManager.instance.isKeyDown(KeyCode.UP))
{
if (this.mcLink.y + this.mcLink.height > this.stage.stageHeight || this.mcLink.y - this.mcLink.height <= 0)
{
this.mcLink.y += 15;
mcLink.gotoAndPlay("Idle");
return;
}
this.mcLink.y -= _nHeroMovementSpeed;
mcLink.gotoAndPlay("Up");
}
if (KeyboardManager.instance.isKeyDown(KeyCode.LEFT))
{
if (this.mcLink.x + this.mcLink.width > this.stage.stageWidth || this.mcLink.x - this.mcLink.width <= 0)
{
this.mcLink.x += 15;
mcLink.gotoAndPlay("Idle");
return;
}
this.mcLink.x -= _nHeroMovementSpeed;
mcLink.gotoAndPlay("Left");
}
else if (KeyboardManager.instance.isKeyDown(KeyCode.RIGHT))
{
if (this.mcLink.x + this.mcLink.width > this.stage.stageWidth || this.mcLink.x - this.mcLink.width <= 0)
{
this.mcLink.x += -15;
mcLink.gotoAndPlay("Idle");
return;
}
this.mcLink.x += _nHeroMovementSpeed;
mcLink.gotoAndPlay("Right");
}
}
}
公共函数enterFrameHandler($e:Event):无效
{
if(this.mcLink)
{
if(KeyboardManager.instance.isKeyDown(KeyCode.DOWN))
{
如果(this.mcLink.y+this.mcLink.height>this.stage.stageHeight | this.mcLink.y-this.mcLink.height this.stage.stageHeight | this.mcLink.height this.stage.stageWidth | this.mcLink.x-this.mcLink.width | this.stage.mcLink.x-this.mcLink.width你的意思是什么
这一行代码在另一个程序中运行,这与我现在的工作几乎相同。我不确定它是否在我们老师提供的包中
this.stage.addEventListener(Event.ENTER_FRAME, this.enterFrameHandler, false, 0, true);
// ^^^^^^^^^^^ EVENT_FRAME isn't a known Event.