Skip to main content
Known Participant
Nov 30, 2022 5:06 PM UTC
Answered

Action script - move (animate) horizontally

Hi,

I need help solving this.  I have a symbol that i want to move 1920 pixels to the right when i click a button.  I can do this using "Move horizontally".  but this will send the symbol directly.  I want it to move as an animation.

Using the "animate horizontally" snipet, moves the symbol but using a speed, not distance.

 

any help would be appreciated.

 

thanks!

This topic is closed to new replies. Start a new post to keep the conversation going.
JoãoCésar17023019
JoãoCésar17023019Correct answer
Community Expert
Nov 30, 2022 6:28 PM UTC

yes didnt allow me to upload the .fla file.

 

here via wt:

https://we.tl/t-orHAF5ACzc?utm_campaign=TRN_TDL_05&utm_source=sendgrid&utm_medium=email&trk=TRN_TDL_05

 


Thanks.

 

For this case, you can use a Tween.

 

Just replace the code that you have in your file:

import fl.motion.easing.*;
import fl.transitions.Tween;

var tween:Tween;

go.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);

function fl_ClickToPosition(event:MouseEvent):void
{
	tween = new Tween(movedor, "x", Back.easeInOut, movedor.x, 655.4, 1, true);
}

back.addEventListener(MouseEvent.CLICK, fl_ClickToPosition2);

function fl_ClickToPosition2(event:MouseEvent):void
{
	tween = new Tween(movedor, "x", Back.easeInOut, movedor.x, 55.4, 1, true);
}


Regards,

JC

7 replies

JoãoCésar17023019
Community Expert
Community Expert
Nov 30, 2022 5:12 PM UTC

Hi.

 

You can use a tween to animate the symbol instance and then set a button to play this timeline on click.

 

Or can't you use timelines?

 

Please let us know.

 

Regards,

JC

Translate
oro1985Author
Known Participant
Nov 30, 2022 5:40 PM UTC

Hi Joao, I prefer not to use timeline,

 

here an example of what i want to do, here i have atwo button that nmove a symbol right and left.  I would like to object to animate to te next possition, not to jump the 600 pixels...

Translate
JoãoCésar17023019
Community Expert
Community Expert
Nov 30, 2022 5:50 PM UTC

OK. No problem.

 

Did you try to attach some file? There isn't any in your comment.

 

If it's an FLA, you're gonna have to upload it to a file sharing service (e.g.: Creative Cloud, Google Drive, Dropbox, WeTransfer...) and paste the link to the file here.

Translate