Reputation: 21
in my AS3 Code I have added this simple EventListener:
addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
there are no errors or anything else, but when I trace something in my mouseMoveHandler it doesn't export something to my console
protected function mouseMoveHandler(event:MouseEvent):void
{
trace("mouseMoved")
}
First I thought this problem shouldn't be so difficult, and I suspect that this has something to do with the stage (addEventListener isn't at the top of it). When I googled it I found something about bubbling, but this just works with dispatch Event or? Thank you in advance for your help!
Upvotes: 0
Views: 1354
Reputation: 3951
The stage itself doesn't dispatch a mouseMove - actually i didn't know about it. You rarely work with the stage directly. It works whit a child though as expected.
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
public class TheMouse extends Sprite
{
public function TheMouse()
{
addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
const background:Sprite = new Sprite();
background.graphics.beginFill(0);
background.graphics.drawRect(0, 0, 100, 100);
background.graphics.endFill();
addChild(background);
}
private function mouseMoveHandler(event:MouseEvent):void
{
trace('mouseMoveHandler');
}
}
}
Upvotes: 1