Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Action script - move (animate) horizontally

Explorer ,
Nov 30, 2022 Nov 30, 2022

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!

TOPICS
ActionScript
1.2K
Translate
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

correct answers 1 Correct answer

Community Expert , Nov 30, 2022 Nov 30, 2022

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 Twee
...
Translate
Community Expert ,
Nov 30, 2022 Nov 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

Translate
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
Explorer ,
Nov 30, 2022 Nov 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...

Translate
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
Community Expert ,
Nov 30, 2022 Nov 30, 2022

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
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
Explorer ,
Nov 30, 2022 Nov 30, 2022
Translate
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
Community Expert ,
Nov 30, 2022 Nov 30, 2022

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

Translate
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
Explorer ,
Nov 30, 2022 Nov 30, 2022

Thanks Joao, this is perfect.!

 

Translate
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
Community Expert ,
Nov 30, 2022 Nov 30, 2022
LATEST

Awesome! You're welcome!

Translate
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