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

Reverse Button Action from Frame 130 to 100

Explorer ,
Apr 17, 2013 Apr 17, 2013

This is driving me up the wall, I have yet to finish the problem.

I am creating a presentation that simply scrolls text and a background image from right to left when I click a button. Simple enough, but all hell breaks loose when I want to do this in reverse. I can use the GoToAndPlay command, but this looks pretty unprofessional since it's used in a presentation in the event that I might have to go back. I'd rather flow than snap.

I literally am about to go crazy, and don't tell me to make a layer to fake a reverse.

I was able to start going backwards, but not stop, and I barely know the code yet. Been awhile since I opened this tedious program.

Button is called Backwards1.

TOPICS
ActionScript
4.7K
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

LEGEND , Apr 17, 2013 Apr 17, 2013

The forward code doesn't help show what you did wrong, especially if it works. 

As I described, to go backwards along the timeline you need to continuously step back a frame at a time until you reach the destination frame.  To continuously process something at the frame rate of your file you can use an ENTER_FRAME event listener.

Backwards1.addEventListener(MouseEvent.CLICK, goBack);

function goBack(evt:MouseEvent):void {

      this.addEventListener(Event.ENTER_FRAME, stepBack);

}

function stepBack(e

...
Translate
LEGEND ,
Apr 17, 2013 Apr 17, 2013

Show the cvode you are trying to use for this button.  It should involve continuously calling a prevFrame() function until you reach a particular frame.

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 ,
Apr 17, 2013 Apr 17, 2013

Well that's the probelm, I don't have any code since i've scrapped every attempt, but here's the code for the forward:

Forward2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_32);

function fl_ClickToGoToAndPlayFromFrame_32(event:MouseEvent):void

{

          gotoAndPlay(911);

}

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
Engaged ,
Apr 17, 2013 Apr 17, 2013

You could try using Greensock's TimeLineLite; the example on the page has a demo of play and reverse: http://www.greensock.com/timelinelite/

It's only library I use for animating.

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
LEGEND ,
Apr 17, 2013 Apr 17, 2013

The forward code doesn't help show what you did wrong, especially if it works. 

As I described, to go backwards along the timeline you need to continuously step back a frame at a time until you reach the destination frame.  To continuously process something at the frame rate of your file you can use an ENTER_FRAME event listener.

Backwards1.addEventListener(MouseEvent.CLICK, goBack);

function goBack(evt:MouseEvent):void {

      this.addEventListener(Event.ENTER_FRAME, stepBack);

}

function stepBack(evt:Event):void {

      if(currentFrame == 100){

           this.removeEventListener(Event.ENTER_FRAME, stepBack);

      } else {

           prevFrame();

      }

}

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 ,
Apr 17, 2013 Apr 17, 2013

THANKYOU

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
LEGEND ,
Apr 17, 2013 Apr 17, 2013

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
Explorer ,
Apr 17, 2013 Apr 17, 2013

Well now my probelem is I can only use the button once and it won't stop going back, and once it has gone back the forward buttons won't work:

/* Stop at This Frame

The Flash timeline will stop/pause at the frame where you insert this code.

Can also be used to stop/pause the timeline of movieclips.

*/

stop();

/* Click to Go to Frame and Play

Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and continues playback from that frame.

Can be used on the main timeline or on movie clip timelines.

Instructions:

1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.

*/

Forward2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_9);

function fl_ClickToGoToAndPlayFromFrame_9(event:MouseEvent):void

{

          gotoAndPlay(221);

}

Backwards1.addEventListener(MouseEvent.CLICK, goBack);

function goBack_3(evt:MouseEvent):void {

      this.addEventListener(Event.ENTER_FRAME, stepBack);

}

function stepBack_3(evt:Event):void {

      if(currentFrame == 220){

           this.removeEventListener(Event.ENTER_FRAME, stepBack);

      } else {

           prevFrame();

      }

}

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
New Here ,
Aug 30, 2015 Aug 30, 2015

Hey Mr Murphy just wanna say you rock was able to solve the back issue thank you thank you thank you

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
New Here ,
Jan 31, 2016 Jan 31, 2016

Mr. Ned Murphy thank you very much. The code work perfectly, you saved my day. To others do not forget to change the name to the correct button "that you have", and change number of frame to one you want to stop at "here 100 and 120". Also if there more than one button the code should have another number like these two examples "to avoid duplicate error"

Backwards1.addEventListener(MouseEvent.CLICK, goBack_1);

function goBack_1(evt:MouseEvent):void {

      this.addEventListener(Event.ENTER_FRAME, stepBack_1);

}

function stepBack_1(evt:Event):void {

      if(currentFrame == 100){

          this.removeEventListener(Event.ENTER_FRAME, stepBack_1);

      } else {

          prevFrame();

      }

}

>>>>>

Backwards1.addEventListener(MouseEvent.CLICK, goBack_2);

function goBack_2(evt:MouseEvent):void {

      this.addEventListener(Event.ENTER_FRAME, stepBack_2);

}

function stepBack_2(evt:Event):void {

      if(currentFrame == 120){

          this.removeEventListener(Event.ENTER_FRAME, stepBack_2);

      } else {

          prevFrame();

      }

}

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
New Here ,
Sep 15, 2019 Sep 15, 2019
LATEST
Hi, there! the example was so usefull!!! can you show us the same code for forward?
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