flash as3.0实现用键盘控制移动代码该怎么写,麻烦帮忙补充一下?
以下是在编辑类里面写好的代码,在if哪里要怎样添加键盘控制,如按w键向上移动,请各位大神帮忙补充一下,谢谢各位了!package{importflash.display....
以下是在编辑类里面写好的代码,在if哪里要怎样添加键盘控制,如按w键向上移动,请各位大神帮忙补充一下,谢谢各位了!
package
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;
public class key extends MovieClip
{
public function key()
{
// constructor code
this.addEventListener(Event.ADDED_TO_STAGE,init);
}
function init(evt:Event):void
{
this.stage.addEventListener(KeyboardEvent.KEY_DOWN,MoverKey);
if (evt)
{
}
}
function MoverKey(evt:KeyboardEvent)
{
}
}
} 展开
package
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;
public class key extends MovieClip
{
public function key()
{
// constructor code
this.addEventListener(Event.ADDED_TO_STAGE,init);
}
function init(evt:Event):void
{
this.stage.addEventListener(KeyboardEvent.KEY_DOWN,MoverKey);
if (evt)
{
}
}
function MoverKey(evt:KeyboardEvent)
{
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询