Skip navigation
residentevil750
Currently Being Moderated

Simplify hiding multiple movieclips at start of frame

Sep 12, 2012 12:03 PM

I am trying simplify my code and save space in my actions panel.  At the start of a new frame I have several movieclips hidden (._visible=false) till I call for them to become visible later.

 

This is the frame's AS I would like to condense:

 

MC1._visible=false;

MC2._visible=false;

MC3._visible=false;

 

...etc.

 

I have about 30 MC# movieclips.  Can someone show how to shorten the code so all 30 mcs are hidden you enter the frame?  An array perhaps?

 

Thank you.

 
Replies
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 12, 2012 12:43 PM   in reply to residentevil750

    there's no need for an array but you will use array notation:

     

    for(var i:Number=1;i<=30;i++){

    this["MC"+i]._visible = false;

    }

     
    |
    Mark as:
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 12, 2012 1:54 PM   in reply to residentevil750

    you're welcome.

     
    |
    Mark as:
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 12, 2012 2:47 PM   in reply to residentevil750

    sure. 

     

    however, if the button is a movieclip button, "this" will reference the movieclip button and not the main timeline.  in that situation, use:

     

    var tl:MovieClip=this;

    yourbutton.onRelease=function(){

    for(var i:Number=1;i<=30;i++){

    tl["MC"+i]._visible=false;

    }

    }

     
    |
    Mark as:
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 12, 2012 3:38 PM   in reply to residentevil750

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points