10 Replies Latest reply on Mar 1, 2007 8:51 AM by kglad

    Actionscript Advice!

      Please can anybody out there help!!!

      I have several movieclips which contain buttons to make that mc play. Once all of the buttons in each mc have been released and all mc's have played, I need to be able to gotoAndPlay the next frame or scene. The user shouldn't be able to goto the next frame/scene if all the movie clips haven't played/ buttons released. Does anybody know the actionscript needed to perform such an event???


        • 1. Re: Actionscript Advice!
          mercl Level 1
          hi brimbo69,
          you could count and add one after you press each clip
          var counter = 1;
          on (release) {
          // maybe hide this button so you can't press again on the same MC)

          // maybe have a loop in root that does something like
          if (counter >= 5) {
          } else {
          // keep looping


          • 2. Re: Actionscript Advice!
            Level 7
            You mean if the last Clip is finished it automaticly jumps to some other

            // five clips;
            allCount = 5;

            if (allCount == 0){

            So if you call this function on the last Frame of every of your Clips it
            might do what you need. In case I understood right ...
            • 3. Re: Actionscript Advice!
              brimbo69 Level 1
              Thanks for your reply mercl. You will have to bare with me as my flash actionscript knowledge is rather basic. Would I place the counter code in a frame where the clips are? then change the instance of each mc adding consecutive numbers (mc1,mc2...). Or would I need to add coding to each mc. If its too much hard work explaining to me don't worry.

              Cheers either way
              • 4. Re: Actionscript Advice!
                brimbo69 Level 1
                Yes mate once all of the clips have played, which ever order they are played in, the script to jump/ move on to next frame. As said to mercl my knowledge is well basic so will have to explain like talking to infant!!

                • 5. Re: Actionscript Advice!
                  kglad Adobe Community Professional & MVP
                  attached to the timeline that contains the movieclips (which contain the buttons) you can use the following. change the movieclip names and button names to match the ones you are using:

                  • 6. Re: Actionscript Advice!
                    brimbo69 Level 1
                    Hi Klad,

                    cheers for your help, will try out and let you know...
                    • 7. Re: Actionscript Advice!
                      mercl Level 1
                      each clip adds 1 to the root timeline
                      _root.counter++; (counter = 1, plus 1 = 2, plus 1 = 3, etc...)
                      (so u basically have one release action inside all the clips and they all add one to the counter set somewhere in the root timeline at the beginning (var counter = 1;)

                      if you reach 5 (or whatever) the root
                      (so after you set the counter = 1; you could make a small loop on the root
                      that looks for counter reaching 5 )
                      if (counter >= 5) {
                      // all clips played, do someting like nextFrame();

                      } else {
                      • 8. Re: Actionscript Advice!
                        Level 7

                        Put this in the frameaction of the main timeline in the first frame.

                        // five clips to be played
                        _global.allCount = 5;

                        if (_global.allCount == 0){
                        // reset counter
                        _global.allCount = 5;

                        In the timeline of the other clips/animation put this in the very last


                        Until the function is called 5 times the first/lower timeline will jump
                        to the next frame.
                        • 9. Re: Actionscript Advice!
                          brimbo69 Level 1
                          Hi Kglad,

                          Couple of questions regarding the code you gave me.

                          1. For every movie clip will the code need to be repeated, changing the names for that mc and button?
                          2. Do the buttons have to be on the root timeline or are they okay withn the movie clips?

                          • 10. Re: Actionscript Advice!
                            kglad Adobe Community Professional & MVP
                            1. yes for each movieclip and each button in the movieclip you'll need coding. and each movieclip/button controls a 3rd object (a movieclip).

                            but a nested for-loop may be used to loop through all the movieclips and all the buttons to streamline the coding. the only difficulty with that might be getting the correct movieclip names for the buttons to control.

                            2. the buttons must be in the movieclips for that code to work. i gave code for btn2 that's in mc3. you'll need to use names that reflect the instance names you used.