I wrote a simple game and I want to add custom pointer. I created MovieClip called Pointer, exported it to AS3 and wrote this code:
var pointer:Pointer = new Pointer();
pointer.scaleX=0.1; //that's because cursor turned to be MUCH bigger than needed
pointer.scaleY=0.1;
stage.addEventListener(MouseEvent.MOUSE_MOVE, redrawCursor);
stage.addEventListener(Event.MOUSE_LEAVE, hideCursor);
Mouse.hide();
function redrawCursor (event:MouseEvent):void {
pointer.visible = true;
pointer.x = event.stageX;
pointer.y = event.stageY;
}
function hideCursor (event:Event):void {
pointer.visible = false;
}
I suppose there's nothing to explain -- code is too simple. In the game, on frame 74 some objects are created on the stage. If I paste this code BEFORE generating and adding other MovieClip instances, cursor is actually BEHIND these objects. If I paste this code AFTER, mouse is on top, but MouseListeners don't react at all. What's the problem? :SS