Highlighted

Reverse Button Action from Frame 130 to 100

Explorer ,
Apr 17, 2013

Copy link to clipboard

Copied

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.

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();

      }

}

TOPICS
ActionScript

Views

3.5K

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

Reverse Button Action from Frame 130 to 100

Explorer ,
Apr 17, 2013

Copy link to clipboard

Copied

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.

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();

      }

}

TOPICS
ActionScript

Views

3.5K

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

Copy link to clipboard

Copied

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.

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
Reply
Loading...
Apr 17, 2013 1
Explorer ,
Apr 17, 2013

Copy link to clipboard

Copied

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);

}

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
Reply
Loading...
Apr 17, 2013 0
Engaged ,
Apr 17, 2013

Copy link to clipboard

Copied

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.

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
Reply
Loading...
Apr 17, 2013 0
LEGEND ,
Apr 17, 2013

Copy link to clipboard

Copied

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();

      }

}

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
Reply
Loading...
Apr 17, 2013 1
Explorer ,
Apr 17, 2013

Copy link to clipboard

Copied

THANKYOU

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
Reply
Loading...
Apr 17, 2013 0
LEGEND ,
Apr 17, 2013

Copy link to clipboard

Copied

You're welcome

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
Reply
Loading...
Apr 17, 2013 0
Explorer ,
Apr 17, 2013

Copy link to clipboard

Copied

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();

      }

}

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
Reply
Loading...
Apr 17, 2013 0
New Here ,
Aug 30, 2015

Copy link to clipboard

Copied

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

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
Reply
Loading...
Aug 30, 2015 0
New Here ,
Jan 31, 2016

Copy link to clipboard

Copied

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();

      }

}

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
Reply
Loading...
Jan 31, 2016 0
New Here ,
Sep 15, 2019

Copy link to clipboard

Copied

Hi, there! the example was so usefull!!! can you show us the same code for forward?

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
Reply
Loading...
Sep 15, 2019 0