出于某种原因,我的值没有在函数之外更新。我正在尝试制作一个按钮,例如“加号”,不断向上移动影片剪辑“topArrow”。我认为布尔值是触发它的一种简单方法,但它不会在函数之外进行更新。为什么是这样?
import flash.events.Event;
import flash.events.MouseEvent;
var speed:Number = 1;
plus.addEventListener(MouseEvent.MOUSE_DOWN, arrow_up);
plus.addEventListener(MouseEvent.MOUSE_UP, arrow_stop);
minus.addEventListener(MouseEvent.MOUSE_DOWN, arrow_down);
minus.addEventListener(MouseEvent.MOUSE_UP, arrow_stop);
var move_up:Boolean = false;
var move_down:Boolean = false;
function arrow_up(event:MouseEvent):void
{
trace("button pressed");
move_up = true;
}
function arrow_stop(event:MouseEvent):void
{
move_up = false;
move_down = false;
}
function arrow_down(event:MouseEvent):void
{
move_down = true;
}
while (move_up==true)
{
topArrow.y += speed;
}
while (move_down==true)
{
topArrow.y -= speed;
}
if(move_up)
{
trace("true");
}