5 Replies Latest reply on May 22, 2011 3:39 PM by Ned Murphy

    If Statement with frames

    JKNetDesign Level 1

      Let's say I have 3 buttons.

      Each button goToAndPlays a frame in a movie clip.


      Now let's say below this setup there's another setup like it.

      Basically; if button1 is clicked the helmet_mc goes to frame 2

      which I achieved by

          

      yellow1_btn.onRelease = function() {
          helmet_mc.gotoAndStop(2);


      Here's where I'm stuck.

      I'm looking for the appropriate 'if else' here is pseudo code


      How do I program it so; if helmet_mc is on frame 2,

      then button 4 when clicked helmet_mc goes to frame 5,

      then button 5 when clicked helmet_mc g oes to frame 6,

      then button 6 when clicked helmet_mc goes to frame 7.


        • 1. Re: If Statement with frames
          Ned Murphy Adobe Community Professional & MVP

          There may not be enough info provided to give you an optimum solution yet.  If there were any conditionals, they would likely be relative to each button's code, as in...

           

          button4.onRelease = function() {
              if(helmet_mc._currentframe == 2)
                 helmet_mc.gotoAndStop(5);

              } else {

                 // ???

              }

          }

          1 person found this helpful
          • 2. Re: If Statement with frames
            JKNetDesign Level 1

            First of all I appreciate you assistance.

             

            Here's the link:

            http://www.kabutopendants.com/gold.html

             

            This a pendant generator.

            There's three different colors of gold, yellow, white,  and pink.

             

            The user can choose what gold he wants for the helmet.

            Than choose gold they like for the face mask.

             

            So if you choose a yellow helmet, then when you play around with the face mask options

            the movie clip displays either the yellow helmet with yelow face mask image (frame 5),

            yellow helmet with white face mask image (frame 6),

            or yellow helmet with pink face mask image (frame 7).

             

            Now let's say you want to start off with a white helmet.

            You would click the 'White 14kt gold' button.

            Then you would click on the face mask options to see for example what the white helmet with pink face mask would look like.

             

            All these images are in the helmet_mc

            White helmet with yellow face mask is on frame 8.

            I hope you get the idea from here.

             

            Please let me know how to fill in the rest of the if statement.

            • 3. Re: If Statement with frames
              Ned Murphy Adobe Community Professional & MVP

              I couldn't tell you how to fill out the rest of it even if I wanted to.  You're the only one with detailed knowledge of what's involved.  But here's a followup to what I started with in case you couldn't see what might have gone on in expanding it.  The numbers I use are irrelevant to what you might actually have to use.

               

              button4.onRelease = function() {
                  if(helmet_mc._currentframe == 2)
                     helmet_mc.gotoAndStop(5);

                  } else if(helmet_mc._currentframe == 8){

                     helmet_mc.gotoAndStop(11);

                  } else if(helmet_mc._currentframe == 14){

                     helmet_mc.gotoAndStop(17);

                  }

              }

               

               

               

               

               

              1 person found this helpful
              • 4. Re: If Statement with frames
                JKNetDesign Level 1

                Staring to understand this but I I have two syntax errors.

                Is there any way that the rest of the code interferes with this statement?

                Here is my if statement.

                 

                 

                yellow2_btn.onRelease = function() {
                    if(helmet_mc._currentframe == 2)
                       helmet_mc.gotoAndStop(5);

                 

                    } else if(helmet_mc._currentframe == 3){

                 

                       helmet_mc.gotoAndStop(6);

                 

                    } else if(helmet_mc._currentframe == 4){

                 

                       helmet_mc.gotoAndStop(7);

                 

                    }

                 

                }

                 

                 

                I'm getting two errors, one on this line

                    } else if(helmet_mc._currentframe == 3){
                And another says unexpected '{' encountered.

                • 5. Re: If Statement with frames
                  Ned Murphy Adobe Community Professional & MVP

                  AS2 is rarely good at pointing to the actual problem.  In the code I provided and the ciode you show, there is a missing brace...

                   

                     if(helmet_mc._currentframe == 2){  <-- that one