• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

strange movie clip behavior on drag

Engaged ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

Hi, I am trying to implement drag and drop in Animate Canvas, using JavaScript.  I am using the code below to grab a movie clip and move it around.  The mouse does grab the clip and move it, but as I drag towards the lower right of the stage, the mouse pointer gets farther and farther away from the movie clip (see JPG).  Here's my code.  Is there a fix for this?  Thanks.

Zaffer

this.blueBall_1.on("pressmove", moveBlueBall);

function moveBlueBall(e){
	
	e.currentTarget.x = e.stageX;
	e.currentTarget.y = e.stageY;
	
}

 drag drop anomaly.jpg

TOPICS
Code , How to

Views

109

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Feb 21, 2022 Feb 21, 2022

Thanks Niktendo,

It's not a problem with registration.  Its a problem with globalToLocal.  You have to set the main timeline (exportRoot) global coordinates to local coordinates.  This code makes dragging the blue ball work perfectly:

let blueBall = this.blueBall_1;
let pt;

blueBall.addEventListener("pressmove", moveBlueBall.bind(this));

function moveBlueBall(e){
	blueBall = e.currentTarget;
	pt = exportRoot.globalToLocal(e.stageX, e.stageY);
	e.currentTarget.x = pt.x;
	e.currentTarget.y = pt.y;
...

Votes

Translate

Translate
Community Expert ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

 Make sure your registration point is in the middle of the ball.

 

Screen Shot 2022-02-21 at 6.34.27 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

LATEST

Thanks Niktendo,

It's not a problem with registration.  Its a problem with globalToLocal.  You have to set the main timeline (exportRoot) global coordinates to local coordinates.  This code makes dragging the blue ball work perfectly:

let blueBall = this.blueBall_1;
let pt;

blueBall.addEventListener("pressmove", moveBlueBall.bind(this));

function moveBlueBall(e){
	blueBall = e.currentTarget;
	pt = exportRoot.globalToLocal(e.stageX, e.stageY);
	e.currentTarget.x = pt.x;
	e.currentTarget.y = pt.y;
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines