1
votes

These are the two errors;

1067: Implicit coercion of a value of type Boolean to an unrelated type String.

1049: Illegal assignment to a variable specified as constant.

I want to basically set it so, if mouse is click

the -y speed of symbol helicopter = variable 'speed'

Any help? Thanks

1
Isn't that supposed to be == in comparison instead of = operator?Mahesh

1 Answers

4
votes

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?
  }
}