Skip to main content
Participating Frequently
August 11, 2009
Answered

Changing lots of movieclips at the same time?

  • August 11, 2009
  • 1 reply
  • 390 views

Is there a way to make many movieclips change the same way, off the same line of code.. rather than having to write them all out seperatly?

eg.

If this was the original code...

clip1_mc.onRollOver = function () {

     clip2_mc._visible = false;

     clip3_mc._visible = false;

     clip4_mc._visible = false;

     clip5_mc._visible = false;

     clip6_mc._visible = false;

     clip7_mc._visible = false;

     clip8_mc._visible = false;

     clip9_mc._visible = false;

}         

I would like to be able to compress it to something more like:

clip1_mc.onRollOver = function () {

     clip2_mc, clip3_mc, clip4_mc, clip5_mc, clip6_mc, clip7_mc, clip8_mc, clip9_mc._visible = false;

}

The above doesn't work... but i'm wondering if anyone knows of a method that will work... saving me from having to write so much code in future?

Cheers

Byron

This topic has been closed for replies.
Correct answer Ned Murphy

In anticipation that rolling over any of the buttons would result in a similar result, here's one possible solution:

function hideMCs(skipMC){

     for(i=1; i<10; i++){

          if(i != skipMC)     {

               this["clip"+i+"_mc"]._visible = false;

          }

     }

}

clip1_mc.onRollOver = function () {

     hideMCs(1);

}       

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
August 11, 2009

In anticipation that rolling over any of the buttons would result in a similar result, here's one possible solution:

function hideMCs(skipMC){

     for(i=1; i<10; i++){

          if(i != skipMC)     {

               this["clip"+i+"_mc"]._visible = false;

          }

     }

}

clip1_mc.onRollOver = function () {

     hideMCs(1);

}       

YakamaziAuthor
Participating Frequently
August 11, 2009

You're a genius!! That's superb. Thanks a lot Ned

Ned Murphy
Legend
August 11, 2009

You're welcome