This test doesn't mean anything: MouseEvent.CLICK
is a constant and its value is always "click"
. So (MouseEvent.CLICK)
will always be true
(testing a string returns true if this string is not null).
To check if the mouse is down, you should write something like that:
var mouseDown:Boolean;
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onMouseDown(event:MouseEvent):void
{
mouseDown = true;
}
function onMouseUp(event:MouseEvent):void
{
mouseDown = false;
}
function onEnterFrame(event:Event):void
{
if (mouseDown)
{
helicopter.y += speed;
}
else
{
//maybe fall?
}
}
==
in comparison instead of=
operator? – Mahesh