Skip to main content
Known Participant
November 30, 2022
Answered

Action script - move (animate) horizontally

  • November 30, 2022
  • 1 reply
  • 1382 views

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 has been closed for replies.
Correct answer JoãoCésar17023019

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

1 reply

JoãoCésar17023019
Inspiring
November 30, 2022

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

oro1985Author
Known Participant
November 30, 2022

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...

JoãoCésar17023019
JoãoCésar17023019Correct answer
Inspiring
November 30, 2022

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