Skip to main content
Known Participant
February 15, 2017
Answered

Animate CC JS mouse follower is not aligned with responsive

  • February 15, 2017
  • 2 replies
  • 2969 views

Hello everyone,

I have started a website on Adobe Animate CC, I have done mouse follower with this code:

this.stage.canvas.style.cursor = "none";
this.mouseEnabled = true;
this.addEventListener("tick", fl_CustomMouseCursor.bind(this));

function fl_CustomMouseCursor() {
     this.plus_mc.x = stage.mouseX;
     this.plus_mc.y = stage.mouseY;
     this.black_plus_mc.x = stage.mouseX;
     this.black_plus_mc.y = stage.mouseY;
}

Now when I do the website responsive at publish setting the follower is not aligned with mouse cursor it only get aligned when I position the cursor at top left corner.

I Hope someone can help me!

Thank you,

Khalil

This topic has been closed for replies.
Correct answer ClayUUID

Multiply your coordinates by stage.scaleX and scaleY. Or divide them. One of those two.

2 replies

khsana04Author
Known Participant
February 15, 2017

For now it only works with css solution only which I tried to avoid, I hope there is a solution inside Animate

here what I have added in html file

<style>

  canvas {

  cursor: none !important;

  }

</style>

I had to add "!important" as it didn't work without it

and here is the test

Thank you very much ClayUUID​ and Colin Holgate​ for your help, and I am sorry for slow understanding.

I hope there is a solution

ClayUUIDCorrect answer
Legend
February 15, 2017

Multiply your coordinates by stage.scaleX and scaleY. Or divide them. One of those two.

khsana04Author
Known Participant
February 15, 2017

Hi ClayUUID,

Thank you for the answer, do you mean I have to edit the code like that:

this.stage.canvas.style.cursor = "none";

this.mouseEnabled = true;

this.addEventListener("tick", fl_CustomMouseCursor.bind(this));

function fl_CustomMouseCursor() {

  this.plus_mc.x = stage.mouseX;

  this.plus_mc.y = stage.mouseY;

  this.black_plus_mc.x = stage.scaleX;

  this.black_plus_mc.y = stage.scaleY;

}

Colin Holgate
Inspiring
February 15, 2017

No, he meant:

this.plus_mc.x = stage.mouseX * stage.scaleX;

this.plus_mc.y = stage.mouseY * stage.scaleY;