How to make a smooth drag text in Adobe Animate?

New Here ,
Jan 27, 2021 Jan 27, 2021

Copy link to clipboard

Copied

Hi!

I was looking on the net and I did not find the code - smooth, because drag text is a little hard and not smoothly dragging. How to make a smooth drag text in Adobe Animate?

Please help. Thank you!

 

My code:

var root = this;
var text = root.text;

root.start = function()
{
createjs.Touch.enable(stage);
stage.mouseMoveOutside = true;
text.transitionDelay = 350;
text.transitionEase = createjs.Ease.quintOut;

text.on("mousedown", root.mouseDownHandler);
text.on("pressmove", root.pressMoveHandler, this, false, { min: -430, max: 40 });
};

root.mouseDownHandler = function(e)
{
e.currentTarget.offsetY = stage.mouseY / stage.scaleY - e.currentTarget.y;
};

root.pressMoveHandler = function(e, data)
{
e.currentTarget.y = root.clamp(stage.mouseY / stage.scaleY - e.currentTarget.offsetY, data.min, data.max);
createjs.Tween.get(text).to( text.transitionDelay, text.transitionEase);
};

root.clamp = function(value, min, max)
{
if (value < min)
return min;


if (value > max)
return max;
return value;
};
root.start();

 

TOPICS
Code, How to, Other

Views

45

Likes

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
Adobe Community Professional ,
Mar 02, 2021 Mar 02, 2021

Copy link to clipboard

Copied

LATEST
Hi!In this video I teach how to create a very simple drag and drop game taking into account any stage scale, randomizing positions, and using tweens.It has n...

Likes

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