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

Problems with Next and Back Buttons ActionScript 3.0

New Here ,
Nov 06, 2014 Nov 06, 2014

Hi,

I have set up a Back, Play and Next buttons in a slideshow I am making.  The next and back buttons work correctly until it gets to the end. 


If I press the Next button it goes back to what appears to be Frame 1 and will not go to the next slide. If I press the Back button it will then go to Frame 201 and If I press next again it will go to Frame 1.  It will only go back and forth in between those frames.


If I press the Back button from the beginning it goes through the slide show correctly then it gets stuck at Frame 1.  If I press next button it goes to Frame 121 and gets stuck in between 121 and 1.

I can't figure this out please help.

My code on Frame 1 is:

stop();

play_btn.addEventListener(MouseEvent.CLICK,playslideshow);

function playslideshow(event:MouseEvent) { gotoAndPlay(2); }

forward_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_2);

function fl_ClickToGoToAndStopAtFrame_2(event:MouseEvent):void

{

  gotoAndStop(40);

}

back_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_8);

function fl_ClickToGoToAndStopAtFrame_8(event:MouseEvent):void

{

  gotoAndStop(281);

}

My code on Frame 40 is:

forward_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_7);

function fl_ClickToGoToAndStopAtFrame_7(event:MouseEvent):void

{

  gotoAndStop(121);

}

back_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_9);

function fl_ClickToGoToAndStopAtFrame_9(event:MouseEvent):void

{

  gotoAndStop(1);

}

My code on Frame 121 is:

forward_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_3);

function fl_ClickToGoToAndStopAtFrame_3(event:MouseEvent):void

{

  gotoAndStop(201);

}

back_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_10);

function fl_ClickToGoToAndStopAtFrame_10(event:MouseEvent):void

{

  gotoAndStop(40);

}

My code on Frame 201 is:

forward_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_4);

function fl_ClickToGoToAndStopAtFrame_4(event:MouseEvent):void

{

  gotoAndStop(281);

}

back_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_11);

function fl_ClickToGoToAndStopAtFrame_11(event:MouseEvent):void

{

  gotoAndStop(121);

}

My code on Frame 281 is:

forward_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_5);

function fl_ClickToGoToAndStopAtFrame_5(event:MouseEvent):void

{

  gotoAndStop(1);

}

back_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_12);

function fl_ClickToGoToAndStopAtFrame_12(event:MouseEvent):void

{

  gotoAndStop(201);

}

TOPICS
ActionScript
1.6K
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 ,
Nov 06, 2014 Nov 06, 2014

With the exception of your "play" button, each of your forward and back buttons are telling the playback head to "gotoAndStop()" at some frame. If I follow the buttons, each one sends the playback head to where you are sending it, and then sits there.

If you want your timeline to play when the playback head jumps to a new frame then you either have to add a "play" directive at that new frame, or you need to change your button functions to use "gotoAndPlay" instead of "gotoAndStop".

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 ,
Nov 13, 2014 Nov 13, 2014

Hi Rob,

Thank you for your reply.  I want my forward and backward buttons to go to the next slide and stop.  I don't want them to play after I jump to the next one.  The play button seems to work correctly no matter what frame I am on.  That is not the problem.  The problem is when I go through the slideshow once either playing it or pressing the next or back button.  It stops working and only goes back and forth from slide 201 to 1 or 1 to 121 depending on what direction I have gone.

If I press the play or next button through the whole show it goes through once and gets stuck on frame 201 to 1.

If I press the back button through once then it gets stuck on 1 to 121.

Rachel

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 ,
Nov 13, 2014 Nov 13, 2014

I found the solution!  Flash CS5 Tutorial 6 Click On Button Go To Another Frame.avi - YouTube

I had to Convert to Keyframes each frames I wanted to jump to on the buttons layer.  Then highlight the button and give each another instance name! Like forward1_btn, forward2_btn, back1_btn, back2_btn...  I did that and adjusted the action-script for each button.


Frame 1

stop();

play_btn.addEventListener(MouseEvent.CLICK,playslideshow);

function playslideshow(event:MouseEvent)

{

gotoAndPlay(2);

}

forward1_btn.addEventListener(MouseEvent.CLICK, Shoot_1);

  

function Shoot_1(event:MouseEvent):void

{

  gotoAndStop(40);

}

back1_btn.addEventListener(MouseEvent.CLICK, Back_1);

  

function Back_1(event:MouseEvent):void

{

  gotoAndStop(281);

}

Frame 40

forward2_btn.addEventListener(MouseEvent.CLICK, Shoot_2);

  

function Shoot_2(event:MouseEvent):void

{

  gotoAndStop(121);

}

back5_btn.addEventListener(MouseEvent.CLICK, Back_5);

  

function Back_5(event:MouseEvent):void

{

  gotoAndStop(1);

}

And so on...



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 ,
Nov 13, 2014 Nov 13, 2014
LATEST

I'm glad that you sorted it out.

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