flash as3 键盘控制影片剪辑移动代码无效 怎么回事
这是部分代码(事实上就是flash提供的那段)请各位帮忙看看,想想为什么这段代码不起作用,我知道是因为flash前面有其他代码影响了,但代码太多发不过来,请各位受累帮忙想...
这是部分代码(事实上就是flash提供的那段)
请各位帮忙看看,想想为什么这段代码不起作用,
我知道是因为flash前面有其他代码影响了,但代码太多发不过来,请各位受累帮忙想想可能是什么代码的影响,怎么解决。
太谢谢了!
var upPressed:Boolean = false;
var downPressed:Boolean = false;
var leftPressed:Boolean = false;
var rightPressed:Boolean = false;
mc.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey_5);
stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed_5);
stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed_5);
function fl_MoveInDirectionOfKey_5(event:Event)
{
if (upPressed)
{
mc.y -= 0;
}
if (downPressed)
{
mc.y += 0;
}
if (leftPressed)
{
mc.x -= 5;
}
if (rightPressed)
{
mc.x += 5;
}
}
function fl_SetKeyPressed_5(event:KeyboardEvent):void
{
switch (event.keyCode)
{
case Keyboard.UP:
{
upPressed = true;
break;
}
case Keyboard.DOWN:
{
downPressed = true;
break;
}
case Keyboard.LEFT:
{
leftPressed = true;
break;
}
case Keyboard.RIGHT:
{
rightPressed = true;
break;
}
}
}
function fl_UnsetKeyPressed_5(event:KeyboardEvent):void
{
switch (event.keyCode)
{
case Keyboard.UP:
{
upPressed = false;
break;
}
case Keyboard.DOWN:
{
downPressed = false;
break;
}
case Keyboard.LEFT:
{
leftPressed = false;
break;
}
case Keyboard.RIGHT:
{
rightPressed = false;
break;
}
}
}
各位好心的高手,帮帮忙吧,不胜感激! 展开
请各位帮忙看看,想想为什么这段代码不起作用,
我知道是因为flash前面有其他代码影响了,但代码太多发不过来,请各位受累帮忙想想可能是什么代码的影响,怎么解决。
太谢谢了!
var upPressed:Boolean = false;
var downPressed:Boolean = false;
var leftPressed:Boolean = false;
var rightPressed:Boolean = false;
mc.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey_5);
stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed_5);
stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed_5);
function fl_MoveInDirectionOfKey_5(event:Event)
{
if (upPressed)
{
mc.y -= 0;
}
if (downPressed)
{
mc.y += 0;
}
if (leftPressed)
{
mc.x -= 5;
}
if (rightPressed)
{
mc.x += 5;
}
}
function fl_SetKeyPressed_5(event:KeyboardEvent):void
{
switch (event.keyCode)
{
case Keyboard.UP:
{
upPressed = true;
break;
}
case Keyboard.DOWN:
{
downPressed = true;
break;
}
case Keyboard.LEFT:
{
leftPressed = true;
break;
}
case Keyboard.RIGHT:
{
rightPressed = true;
break;
}
}
}
function fl_UnsetKeyPressed_5(event:KeyboardEvent):void
{
switch (event.keyCode)
{
case Keyboard.UP:
{
upPressed = false;
break;
}
case Keyboard.DOWN:
{
downPressed = false;
break;
}
case Keyboard.LEFT:
{
leftPressed = false;
break;
}
case Keyboard.RIGHT:
{
rightPressed = false;
break;
}
}
}
各位好心的高手,帮帮忙吧,不胜感激! 展开
2个回答
深圳市容大彩晶科技有限公司
2024-11-20 广告
2024-11-20 广告
作为深圳市容大彩晶科技有限公司的工作人员,对于公司广告机的功能有一定的了解。公司的广告机是否支持多语言显示,具体需根据产品型号和功能配置来确定。但一般而言,现代广告机通常具备多语言显示的功能,以适应不同国家和地区的需求。建议直接查阅产品说明...
点击进入详情页
本回答由深圳市容大彩晶科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询