Skip navigation
Currently Being Moderated

Slideshow with buttons will not allow more than one cycle through the timeline.

Apr 13, 2012 12:58 PM

Hi, I'm new to AS3. I have a slideshow with 4 slides. They are all in Scene 1 on the timeline. Each is on its own layer (and I have a fade effect between each of them on the timeline). I added labels to a separate layer in the timeline so that I could use forward and backward buttons to "speed up the process" in essence (instead of waiting for the slide to change). I can successfully use the buttons to cycle through the slideshow one time, but if I try to cycle through the slides more than once, I cannot get any further than the first slide.

 

I put this code on the buttons in the first frame of each labeled section on my timeline:

 

fwd_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_18);

 

function fl_ClickToGoToAndPlayFromFrame_18(event:MouseEvent):void

{

    gotoAndPlay("Shopper_2");

}

 

 

back_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_19);

 

function fl_ClickToGoToAndPlayFromFrame_19(event:MouseEvent):void

{

    gotoAndPlay("Shopper_1");

}

 

Any ideas?

 

Regards,

zerozone

 
Replies
  • Currently Being Moderated
    Apr 13, 2012 8:01 PM   in reply to zerozone110

    Without seeing the timeline I can only hazard a guess.  If you have the same buttons along the full length of the timeline, then what is probably happening is you are assging all those listeners to them, and they all remain in effect, so by the end, clicking them triggers each of the listeners, where the last always wins.

     

    Try using just one listener and function for each button assigned in frame one.  Use variables for the frame designations in the gotoAndPlay() calls.  Then you just need to change the values of the variables at different stages of the timeline.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 16, 2012 9:10 AM   in reply to zerozone110

    The code for the buttons would not change very much and would only be in frame 1.  You would only be changing the functions to use variables for the gotoAndPlay() class

     

    var fwdFrame:uint = ???; // use  whatever the value would be for the goto in frame 1 normally

    var backFrame = 1;

     

    fwd_btn.addEventListener(MouseEvent.CLICK, fl_goForward);

     

    function  fl_goForward(event:MouseEvent):void {

         gotoAndPlay(fwdFrame);

    }

     

    back_btn.addEventListener(MouseEvent.CLICK, fl_goBack);

     

    function fl_goBack(event:MouseEvent):void {

         gotoAndPlay(backFrame);

    }

     

    Make sure that layer extends the full tlength of the timeline so that the variables and functions are available all along it.

     

    Then you just need to change the values of fedFrame and backFrame at each new stopping point on the timeline.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 16, 2012 1:14 PM   in reply to zerozone110

    Don't redeclare the variables, just reassign them....

     

    fwdFrame = "retailer_1";

    backFrame = 1;

    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 16, 2012 3:27 PM   in reply to zerozone110

    If you are going to use frame labels, then declare the variables as strings,  If you are going to use frame numbers, declare the variables as uint or int.  Stick with one type for all of them

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2012 6:34 AM   in reply to zerozone110

    Frame labels (which are strings) is a better choice, especially if you anticipate changing the timeline.  So you would just need to keep them all as String objects when you declare and assign them...

     

    // frame 1

    var fwdFrame:String = "retailer_1";

    var backFrame:String = "someOtherLabel";

     

     

    // other frames

    fwdFrame = "omeOtherLabel3";

    backFrame = "someOtherLabel2";

     

     

     

     

    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points