11 Replies Latest reply on Nov 30, 2006 10:38 AM by Newbie1234

    Fl8: If, then, else statements?

      What is the actionsript for doing this. Something to do with If,Then, Else statements:

      If movieclip1 has played and reached frame 60,
      Then when button1 is clicked, movieclip2 is played,
      else if movieclip1 has not played and reached frame 60, and button1 is clicked,
      Then a msgbox will pop up on screen with some text to tell u that.

      P.S. I guess the code is suppose to go on button1? Please help me. Thanks
        • 1. Re: Fl8: If, then, else statements?
          arunbe Level 1
          You can use the (moviclip1._currentframe == 60) condition to find out its reached the 60th frame or not !
          • 2. Re: Fl8: If, then, else statements?
            Newbie1234 Level 1
            Thanks for that. Still stuck though. this is what I wrote:

            If (_root.Boatmc._currentframe == 60) {
            then on(release)
            gotoAndPlay (20) }
            { else

            - _root.boatmc returns an error, and after 'else' I don't know what to write. any ideas?
            • 3. Re: Fl8: If, then, else statements?
              IF ( ) {

              } ELSE {

              • 4. Re: Fl8: If, then, else statements?
                clbeech Level 3
                well, it appears that you have the syntax wrong here, and a few other things. First ace the use of _root, it's not necessay. Retitle the instance name of 'Boatmc' to 'Boat_mc' AS will read it better as a MovieClip (just convention). Next there are no "then" statement keywords used in AS. An 'onRelease statement must be associated with a button or MovieClip.

                So you need to restructure things a little bit. If you want this action to happen on the press of the button1, first of all name the instance "button1_btn" or something like that. then write on the first frame of the timeline ...

                button1_btn.onRelease = function() {

                if(Boat_mc._currentframe == 60) {
                alertclip_mc.visible = true;


                Now 'alertclip_mc' is your message MovieClip that you must create, there are other ways to accomplish this, but it's just as easy to do this in the context of your SWF than use a Java function. Also a 60 frame clip would only take a few second to complete therefore, i don't really see the need to have an alert to inform the viewer that it's not completed, by the time they read the alert the clip will be done playing. I would think that you could just 'disable' the button until the clip completes, then 're-enable' the button afterward. Also if creating an 'alertclip_mc', you will need a method to turn it off, so on the last keyframe write something like...

                this.visible = false;

                and it will go away.
                anyway all I can do for now.
                • 5. Re: Fl8: If, then, else statements?
                  clbeech Level 3
                  do not use CAPS for your 'if' and 'else' keywords.
                  • 6. Re: Fl8: If, then, else statements?
                    Newbie1234 Level 1
                    hi cbeech.

                    the code you have given me should work. there are no syntax errors. But for some reason, when the movie is played, and I select the button, nothing happens. My guess is something to do with the frame 60? Movieclip1 does play all the way to frame 60. I put all the animations within this movieclip1.

                    i dont understand why it doesnt work. any ideas?
                    • 7. Re: Fl8: If, then, else statements?
                      Newbie1234 Level 1
                      I think I might know what the problem is. i need it to say when the movieclip1 has played up to frame 60 INSIDE of that movieclip. Not outside of it if that makese sense. thats probably why it isn't working? How do you do that?
                      • 8. Re: Fl8: If, then, else statements?
                        clbeech Level 3
                        It's hard to tell without seeing the rest of your SWF structure, can you post a link to the file?

                        I'm just guessing here, but do you have a stop(); action on frame 60?
                        • 9. Re: Fl8: If, then, else statements?
                          Newbie1234 Level 1
                          Yes there is a stop() action on frame 60 to answer your question.
                          • 10. Re: Fl8: If, then, else statements?
                            clbeech Level 3
                            OK, got the file. I see what your trying to do now, however I'm sorry to say that we've got a ways to go. yes i see the stop() on frame 19 of the lockwater MC. but all statement must end with " ; " semi-colon as in, "stop(); " the frame that your calling on is 19 not 60, and I noticed that you have keyframed the animation individually, there are some much more efficient ways to accomplish this, firstly by using the "createMotionTween' and "createShapeTween" comands, and it will change from one shape or postion to another automatically, wherein you can also provide easing functions to animate things with more control. there are also ways in which to create Tweens using AS, but let's stick to the basics for now.

                            Also, I noticed on first inspection that most of you MC clips and buttons do not have instance names, and individual action layers. It's a 'best practice' not to put your code on frame that contain drawing or movieclip symbols.

                            give me a little time with this and I can work some things out for you, and help you get moving in the right direction.
                            • 11. Re: Fl8: If, then, else statements?
                              Newbie1234 Level 1
                              Ok. Thanks for that.

                              P.S. you can email me straight away with the email address I gave you if you like (instead of going through the forum)!

                              Thanks again!