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个回答
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询