4 Replies Latest reply on Aug 11, 2011 3:34 AM by klas_tauberman

    How do I inactivate all other movie clips except the running one.

    klas_tauberman

      Hello guys

       

      I would need help to inactivate all other actions on movie clips while the active movie clip is running. So in my flash scen when the user makes a roll over on a movie clip I would like that movie clip to play all frames in that movie clip before the user can roll over on an other movie clip. So the active movie clip don't gets interupted. What actionscript 2.0 should I look for?

       

      Thanks!

       

      /Klas

        • 1. Re: How do I inactivate all other movie clips except the running one.
          Ned Murphy Adobe Community Professional & MVP

          You could use a boolean variable in a conditional that wraps whetever functionality the objects have to prevent them from taking those actions.  So when you rollover an object it starts to activate its animation or whatever and sets that boolean to prevent any others from doing the same.  And when it completes its actions it rets the boolean.

           

          If you show your rollover code it might be easier to show an example, but it might be something like...

           

          var allowPlay = true;

           

          mc1.onRollOver = rolloverFunction;
          mc2.onRollOver = rolloverFunction;
          mc3.onRollOver = rolloverFunction;

           

          function rolloverFunction(){

             if(allowPlay){

                 allowPlay = false;

                 this.play(); // or whatever action your rollover executes

             }

          }

           

          and when that animation completes the movieclip resets the allowPlay to true.

           

          _root.allowPlay = true;

          1 person found this helpful
          • 2. Re: How do I inactivate all other movie clips except the running one.
            klas_tauberman Level 1

            Thanks Ned!

             

            It is a small game. A girl that moves over a scen and triggers movie clips on rolI overs. Here is the code:

             

             

            door_swe_mc.stop();

            house_mc.stop();

            bush_mc.stop();

            plank_mc.stop();

            girl_mc.stop();

             

            //Creates a loop- the code inside this function loops over and over.

            girl_mc.onEnterFrame = function()

            {

             

            //Repositions girl_mc on the mouse cursor: As is it inside the loop, it does this over and over giving the appearance that the girl is following the mouse

            this._x = _xmouse;

            this._y = _ymouse;

            }

             

            door_swe_mc.onRollOver = function(){

            door_swe_mc.gotoAndPlay("open");

            }

             

            door_swe_mc.onRollOut = function(){

            door_swe_mc.gotoAndPlay("closed");

            }

             

            house_mc.onRollOver = function(){

            house_mc.gotoAndPlay("over");

            }

             

            house_mc.onRollOut = function(){

            house_mc.gotoAndPlay("back");

            }

             

            bush_mc.onRollOver = function(){

            bush_mc.gotoAndPlay("over");

            }

             

            bush_mc.onRollOut = function(){

            bush_mc.gotoAndPlay("back");

            }

             

            So I don't want the girl to be able to trigger the other movie clips until the active on is finished.

             

            Could you please show me your example again with your boolean variable on this code? I'm a beginner on this.

             

            Thanks!

             

             

            • 3. Re: How do I inactivate all other movie clips except the running one.
              klas_tauberman Level 1

              Hi Ned

               

              I can't really get it working. It only plays on of the movieclips once and then nothing more happens. It's like it don't get backs to it initial state, or don't release the allowPlay = false state after the movie clip has ended. The code looks like this:

               

              var allowPlay = true;

               

              door_swe_mc.onRollOver = rolloverFunction;

              husgavel_mc.onRollOver = rolloverFunction;

              bush_mc.onRollOver = rolloverFunction;

              plank_mc.onRollOver = rolloverFunction;

               

              function rolloverFunction(){

                 if(allowPlay){

                     allowPlay = false;

                     this.play(); // or whatever action your rollover executes

                 }

              }

               

              //and when that animation completes the movieclip resets the allowPlay to true.

               

              _root.allowPlay = true;

               

               

              /Klas

              • 4. Re: How do I inactivate all other movie clips except the running one.
                klas_tauberman Level 1

                Thank you Ned! Your code did it!. It just took me some time to figure out how I should implement it in my code.