Copy link to clipboard
Copied
Hi there,
I'm working on a project in Adobe Animate cc 2017 where I have a movieclip that I'd like to drag along the Y axis using the mouse. I was able to get a draggable object within a bounding box with the help I received on an earlier forum post - Createjs - dragging an object within a bounding box . I didn't notice anything strange with the dragging function then, however now I'm doing a new project which also needs a draggable object and it works, but when I click on the movieclip to drag it, the movieclip will jump down a bit from the mouse - since I'm dragging within a bounding box this becomes an issue when the movieclip jumps down to the bottom of the bounding box and is difficult to drag back up. Any ideas why the movieclip is 'jumping' away from the mouse when I click it on it to drag it? It's like there is some invisible offset between where the mouse is on the stage and the movieclip.
Here is the code I'm using: (my movieclip instance name is 'yoke').
var yokeHeight = 2; //actually half the height
var bounds = {x:65, y:415, width:220, height:60};
var yoke = this.yoke;
var sliderBoundary = new createjs.Shape();
sliderBoundary.graphics.beginStroke("#999")
.setStrokeStyle(0)
.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
this.stage.addChild(sliderBoundary);
sliderBoundary.visible = false;
this.yoke.addEventListener("pressmove", fl_MouseClickHandler_2.bind(this));
function fl_MouseClickHandler_2(evt){
evt.currentTarget.y = Math.max(bounds.y + yokeHeight, Math.min(bounds.y + bounds.height - yokeHeight, evt.stageY));
}
yoke.x = 160;
yoke.y = bounds.y + bounds.height / 2;
Any help is much appreciated!
Thanks.
Copy link to clipboard
Copied
check yoke's reg point.
Copy link to clipboard
Copied
The reg point is right in the center. I tried moving it around and it doesn't seem to affect the jump away from the mouse on first click, just changes where it appears at first load.
Copy link to clipboard
Copied
check if the problem is there with other browsers.