4 Replies Latest reply on Oct 31, 2006 2:45 AM by Newsgroup_User

    How can I find the children of a movie clip?

    jgeorg
      Hi all,
      I wander if there is a clever way to get a list or an array with the children of a movie clip.
      i.e. this._children

      Thanks in advance
        • 1. How can I find the children of a movie clip?
          DazFaz Level 1
          for(var i in myMovieClipName){
          trace(i);
          }
          then to take it a little further:
          for(var i in myMovieClipName){
          trace(typeOf(eval(i));// will return what acually is
          }
          • 2. Re: How can I find the children of a movie clip?
            Level 7
            DazFaz wrote:
            > for(var i in myMovieClipName){
            > trace(i);
            > }

            If you want to have Movieclips only, you should ...

            for(var i in myMovieClip){
            if (typeof (myMovieClip ) == "movieclip"){
            trace(i + "=" + myMovieClip
            );
            }
            }


            Otherwise you will get _everything_: functions, variables, objects etc.
            • 3. Re: How can I find the children of a movie clip?
              DazFaz Level 1
              castten, what you have put:

              >If you want to have Movieclips only, you should ...
              >
              >for(var i in myMovieClip){
              >if (typeof (myMovieClip) == "movieclip"){
              >trace(i + "=" + myMovieClip);
              >}
              >}

              WILL return "movieclip" because you are evaluating the actual movieClip that contains everything else. All you are doing in the above is the comparing the same movie repeatedly.

              What I’ve put in my previous post:

              for(var i in myMovieClipName){
              trace(typeOf(eval(i));// will return what actually is
              }

              Will do what the member is asking.

              If you don’t evaluate the "i" value, it will return a "String" only.
              • 4. Re: How can I find the children of a movie clip?
                Level 7
                DazFaz wrote:
                > castten, what you have put:
                >
                > >If you want to have Movieclips only, you should ...
                > >
                > >for(var i in myMovieClip){
                > >if (typeof (myMovieClip) == "movieclip"){
                > >trace(i + "=" + myMovieClip);
                > >}
                > >}
                >
                > WILL return "movieclip" because you are evaluating the actual movieClip that
                > contains everything else. All you are doing in the above is the comparing the
                > same movie repeatedly.

                true

                > What I?ve put in my previous post:
                >
                > for(var i in myMovieClipName){
                > trace(typeOf(eval(i));// will return what actually is
                > }
                >
                > Will do what the member is asking.

                Not. It will get every i (string) property of "this" (=eval in this
                case) and "this" isn't necesarely "myMovieClip".

                > If you don?t evaluate the "i" value, it will return a "String" only.

                "i" is the property or clip name, true.


                Try this:

                for(i in myMovieClip){
                if (typeof (myMovieClip ) == "movieclip"){
                trace(i + "=" + myMovieClip
                );
                }
                }