2 Replies Latest reply on Jun 15, 2009 2:53 AM by David Beedle

    Acquiring movieclip instance names

    David Beedle Level 1

      I need to write a function that retrieves the instance names of movie clips without knowing what those instance names are.

       

      Here's the scenario:

       

      The timeline reaches a frame which has a movieclip with an instance name of "bigClip"

       

      bigClip itself holds a number of movieclips, each with its own unique instance name. On the enterFrame of bigClip, I want to retrieve all the instance names that are on bigClip and put them in an array.

       

      I can't seem to figure this out. Any guidance would be much appreciated.

       

      Thanks,

      David

        • 1. Re: Acquiring movieclip instance names
          Rothrock Level 5

          Well I doubt you want to do it on the enterframe of bigClip. Do you really need to find the names of all the clips 30 times a second every second that big clip exists? I'm guessing/hoping you just mean when bigClip starts.

           

          In any event you can make a function that returns an array. Perhaps something like this:

           

          function findChildrenClips(clip:MovieClip):Array{

          var theClips:Array=new Array();

          for(var a in clip){

          if(typeof(clip[a])=="movieclip"){

          theClips.push(clip[a]);

          }

          return theClips;

          }

           

          Then on the frame where big clip exisits you can do this:

           

          var foundClips:Array=findChildrenClips(bigClip);

           

          Now if you really want to do this onEnterFrame you could probably do it, but there is probably a better way to structure your file in that case.

          • 2. Re: Acquiring movieclip instance names
            David Beedle Level 1

            Thanks so much. And yes, you're correct... using it in an onEnterFrame would not be the way to go.