A rectangle that you can drag around.
I want to create a rectangle that I can move by clicking and dragging it. The rectangle stays in place after I stop dragging it.
Using Adobe Animate CC with html5 canvas, how can this be done?
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityvar root = this;
var rec = root.rec;
createjs.Touch.enable(stage);
rec.on("mousedown", function(e)
{
e.currentTarget.offsetX = stage.mouseX / stage.scaleX - e.currentTarget.x;
e.currentTarget.offsetY = stage.mouseY / stage.scaleY - e.currentTarget.y;
});
rec.on("pressmove", function(e)
{
e.currentTarget.x = stage.mouseX / stage.scaleX - e.currentTarget.offsetX;
e.currentTarget.y = stage.mouseY / stage.scaleY - e.currentTarget.offsetY;
});