user2896120
user2896120

Reputation: 3282

Why is my custom cursor slow?

I just made a custom cursor using this code:

function initializeGame():void
{
cursor = new Cursor();
addChild(cursor);
cursor.enabled = false;
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
}

function dragCursor(event:MouseEvent):void
{
cursor.x = this.mouseX;
cursor.y = this.mouseY;
}

initializeGame();

The anchor point is registered in the top left hand corner. The problem that I am having is that the cursor is very laggy. My custom cursor contains no animation, it is just a cross hair. Is there any way to make it move faster like a regular cursor?

Upvotes: 0

Views: 616

Answers (3)

elahehab
elahehab

Reputation: 335

try using Event.ENTER_FRAME instead of MouseEvent.MOUSE_MOVE if possible. I did it and it made speed much better

Upvotes: -1

Rony
Rony

Reputation: 142

There is a much better way to use custom cursors, check this tutorial - Working with native mouse cursors in Flash Player 10.2

Upvotes: 0

Fygo
Fygo

Reputation: 4665

There is. You should update the screen (make a redraw) upon every mouse move. Add this to your mouse move listener:

event.updateAfterEvent();

Upvotes: 3

Related Questions