trial Posted March 15, 2022 Share Posted March 15, 2022 (edited) Hello, based on the createjs drag and drop demo, I'm trying to make it so that the circle jumps to the position of the cursor/touch on mousedown. I managed to make the dragging work, but no idea how to make the circle jump to position. createjs.Touch.enable(stage); this.circle_mc.on("pressmove", function (evt) { var point = stage.globalToLocal(evt.stageX, evt.stageY) evt.currentTarget.x = point.x; evt.currentTarget.y = point.y; stage.update(); }); Can anyone help it do something like this? Update: Managed to get it to work using this code in animate: var _this = this; stage.on("stagemousedown", function (evt) { var point = stage.globalToLocal(evt.stageX, evt.stageY) _this.circle_mc.x = point.x; _this.circle_mc.y = point.y; var moveAround = stage.on("stagemousemove", function (evt) { var point = stage.globalToLocal(evt.stageX, evt.stageY) _this.circle_mc.x = point.x; _this.circle_mc.y = point.y; }); stage.on("stagemouseup", function (evt) { stage.off("stagemousemove", moveAround) }, null, true) }); Edited March 16, 2022 by trial Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.