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

Drag and drop smoothly Animate CC Canvas

Community Beginner ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

I am using Animate CC, Canvas, I'm trying to drag my background scene along the X axis, the code I have so far is

this.scene.addEventListener("pressmove", dragMe.bind(this));  function dragMe (evt) { this.addChild(evt.currentTarget); var p = this.globalToLocal(evt.stageX, evt.stageY); evt.currentTarget.x = p.x; }

However each time I drag the background it snaps the image to the mouse (depending on where the axis - rotation point - is placed in Animate CC). This makes for an unsmooth drag, I would like something more like a touch screen interaction where I can just keep dragging/swiping it along.

I can't seem to find a solution anywhere for this.

Thanks in advance.

Views

1.9K

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

Community Expert , Nov 17, 2017 Nov 17, 2017

Yes - by default, the x and y are calculated from teh registration point.

Have a look at the following example as it seems to accomplish what you are looking to do:

Draggable Canvas - JSFiddle

Votes

Translate

Translate
Community Expert ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

Yes - by default, the x and y are calculated from teh registration point.

Have a look at the following example as it seems to accomplish what you are looking to do:

Draggable Canvas - JSFiddle

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
Community Beginner ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

Wow! Yes!!! This is exactly what I was looking for, that's perfect thanks! I knew there had to be a way.

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
Community Beginner ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

Hi,

Please excuse my ignorance, I really am just starting to learn all this.

Within Animate CC I can't seem to find a way to give the canvas an id, so the code can't reference anything and therefore the drag doesn't work (or at least I assume that's the issue).

Have you any idea how to make this work in Animate CC or am I just making my life complicated?

Thanks again

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
LEGEND ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

LATEST

The canvas is given the ID "canvas".

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