7 Replies Latest reply on Apr 3, 2013 9:15 AM by sjc77

    Simple button script not working

    sjc77

      I am using AS2 and need help figuring out why this simple button script is not working:

       

      stop();

      buttonWS1.onRelease = function(){

                          gotoAndStop("Stage1and2_Boss",4);

      };

      buttonWS2.onRelease = function(){

                          nextFrame();

      };

      //end

       

      My buttons are the square letter-puzzles below. They are images that I converted to "symbols" (specifically, buttons). I put their names as above (buttonWS1, buttonWS2, etc.) in the "instance names" boxes.

       

      I have no idea what is going on. Please help!

      Screen Shot 2013-04-02 at 9.54.32 PM.png

        • 1. Re: Simple button script not working
          kglad Adobe Community Professional & MVP

          buttonWS1 is problematic but buttonWS2 should work.  does it advance the timeline that contains that code to the next frame?

          • 2. Re: Simple button script not working
            sjc77 Level 1

            Thanks for the response. Neither works. Neither advances the timeline. I have to put a continue button on the page for it to advance.

             

            The strange thing is that at one point I got one of the puzzles to work as a button. But then i changed all the images, and I can't get even one of them to work.

             

            Any ideas?

             

            Message was edited by: sjc77

            • 3. Re: Simple button script not working
              kglad Adobe Community Professional & MVP

              go to the frame that contains your button code.

               

              click on the object you think is buttonWS2. 

              1. check the properties panel to see if buttonWS2 is listed as that button's instance name.

              2. make sure there's no code attached to that button

               

              if both those check out, add a trace statement to that button's onRelease and check if the onRelease executes by clicking it and watching for the trace output.

              • 4. Re: Simple button script not working
                sjc77 Level 1

                Hi -

                 

                1. Yes, buttonWS2 is the instance name

                2. The only code attached to it is the code I pasted above.

                3. onRelease does not execute because my trace statement does not appear in the output

                 

                Here is the modified code for buttonWS2:

                 

                buttonWS2.onRelease = function(){

                                    trace("clicked!");

                                    nextFrame();

                };

                 

                Question: It shouldn't matter if I have commented-out code within that set of codes should it?:

                 

                buttonWS2.onRelease = function(){

                          //if (puzzleschosenarray[0] == 2 || puzzleschosenarray[1] == 2) {

                          // cannot be chosen -- make button non-functional

                          //}

                          //else{

                                    //puzzleschosenarray[roundnumber-1] = 2;

                                    trace("clicked!");

                                    nextFrame();

                          //}

                };

                • 5. Re: Simple button script not working
                  kglad Adobe Community Professional & MVP

                  your commented code looks good.

                   

                  now take and attach 2 screenshots.  one that shows your timeline and buttonWS2 selected on stage and shows the properties panel so i can confirm buttonWS2 is named correctly and a second that shows your timeline and the actions panel with the latest buttonWS2.onRelease.