6 Replies Latest reply on Jun 9, 2011 2:12 PM by feffer1218

    ActionScript 2 issues: previous button not working

    feffer1218

      Hello,

       

      I am trying to create a slideshow in Flash CS4 using ActionScript 2.

      I have imported "pause" and "play" buttons from the libraries, and I have created "next" and "previous" buttons by using the PolyStar tool.

      Here is my problem: The "previous" button is not working. However, the other buttons (even the "next" button, which only really has the opposite code) do work.

      I am writing all of my code in the frames, which probably isn't the best idea, but it would be hard for me to change now.

       

      Code (an example code frame)(currently on the 1st frame):

      prev.onPress = function(){

      gotoAndStop("14");

      }

      begin.onPress = function(){

      play();

      }

      pause.onPress = function(){

      stop();

      }

      next.onPress = function(){

      gotoAndStop("2");

      }

       

      previous.onPress = function(){

      gotoAndStop("14");

      }

       

      "prev" is an instance of "previous". "begin", "next", and "pause", are instances of a play button, "next", and a pause button. I am using frame labels that go from "1" to "14".

       

      What am I doing wrong?

       

      feffer1218

        • 1. Re: ActionScript 2 issues: previous button not working
          kglad Adobe Community Professional & MVP

          remove that previous.onPress code and remove the quotes from those frame numbers.  if you want to use frame labels, they should be strings that do NOT start with a number.

          • 2. Re: ActionScript 2 issues: previous button not working
            feffer1218 Level 1

            Thanks for your advice, but it didn't work.

            1. I changed all of my frame labels so that they have the letter "p" in front of all of them. (ex: "p1" instead of "1")

            2. I commented out the "previous.onPress" code.

             

            2 examples of code:

             

            //p1 (first photo)

            prev.onPress = function(){
                gotoAndStop("p14");
            }
            begin.onPress = function(){
                play();
            }
            pause.onPress = function(){
                stop();
            }
            next.onPress = function(){
                gotoAndStop("p2");
            }

             

            /*previous.onPress = function(){
                gotoAndStop("14");
            }*/

             

            //p2 (second photo)

            begin.onPress = function(){
                play();
            }
            pause.onPress = function(){
                stop();
            }
            next.onPress = function(){
                gotoAndStop("p3");
            }
            prev.onPress = function(){
                    gotoAndStop("p1");
               
            }

             

            I don't know what I'm doing wrong! The Properties window says that "prev" is an "instance of: previous."

             

            Any ideas? Thanks for the attempt, though.

             

            feffer1218

            • 3. Re: ActionScript 2 issues: previous button not working
              kglad Adobe Community Professional & MVP

              do you mean:

               


               

              //on frame "p1"

              prev.onPress = function(){
                  gotoAndStop("p14");
              }
              begin.onPress = function(){
                  play();
              }
              pause.onPress = function(){
                  stop();
              }
              next.onPress = function(){
                  gotoAndStop("p2");
              }

               

               

               

              //on frame "p2"

              begin.onPress = function(){
                  play();
              }
              pause.onPress = function(){
                  stop();
              }
              next.onPress = function(){
                  gotoAndStop("p3");
              }
              prev.onPress = function(){
                      gotoAndStop("p1");
                 
              }

               


              • 4. Re: ActionScript 2 issues: previous button not working
                feffer1218 Level 1

                "p1" and "p2" are frame labels. If that is what you are talking about, then yes.

                There is a different frame label for each photo.

                 

                My project is set up as so:

                 

                Layer 1: actions layer; all of my ActionScript goes on this layer.

                Layer 2: frame labels: "p1", "p2", "p3"...

                Layer 3: actual pictures

                 

                Stage: because the actions layer and the labels layer are transparent, I have two arrows that change a picture between them (on the pictures layer). Below each picture are pause and play buttons.

                (it plays on its own until an arrow or pause button is pressed. If an arrow is pressed, gotoAndStop is used to get to another picture; if pause is pressed, stop() is called; play calls play() to get the slideshow running again)

                Only the picture changes; the buttons stay in their place from frame to frame.

                 

                Does this give any ideas?

                 

                feffer1218

                • 5. Re: ActionScript 2 issues: previous button not working
                  kglad Adobe Community Professional & MVP

                  you must have code in each labeled frame.  do you?

                  • 6. Re: ActionScript 2 issues: previous button not working
                    feffer1218 Level 1

                    I did not have code in the frames with labels.

                    I put code there, but that did not help.

                    However, I found my own solution.

                    I created a new button, since my "previous" button was created partially from the "next" button.

                    I thought that this was screwing things up, so I started from scratch.

                    After that, all I did was apply code to the button instead of the frame.

                     

                    Code:

                    //for the "previous" button:

                    on (press)

                    {

                         gotoAndStop("p14");

                    }

                     

                    I don't know why my other approach did not work, but this one does.

                    As long as my slideshow runs, I'm happy.

                     

                    feffer1218