7 Replies Latest reply on Mar 8, 2007 4:18 PM by Capo64

    Movie Clip array?

    Capo64
      Is it possible to put multiple movie clips in one array? So if I have myArray[1] = mov_mc, I can do myArray[1].gotoAndPlay(2) and it will do so.
        • 1. Re: Movie Clip array?
          Level 7
          Capo64,

          > Is it possible to put multiple movie clips in one array?

          Yes.

          > So if I have myArray[1] = mov_mc, I can do
          > myArray[1].gotoAndPlay(2) and it will do so.

          Indeed. :)


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Movie Clip array?
            Capo64 Level 1
            Well, I've been trying and I have no luck. I have a movie clip and I tried assigning it to a variable. It half worked.. I can say trace(myVar._x); and it will return the x coord of the movie clip, but when i say myVar.gotoAndPlay(2); it doesn't do so.
            • 3. Re: Movie Clip array?
              kglad Adobe Community Professional & MVP
              you're doing something wrong or you're trying to access myVar when it doesn't exist. post your code if you're sure your movieclip exists and you're sure it's not responding to its gotoAndPlay() method.
              • 4. Movie Clip array?
                Capo64 Level 1
                ma = new MovieClip();
                ma = bad_mc;
                ma.gotoAndPlay(2);
                stop();

                that's in my first frame.
                I have a movie clip in that frame with a stop(); on it's first frame, and a tween starting at its second frame. So it should start playing the tween when the frame loads, right?
                Edit:
                nvm, Something's going on with this.. When i tried bad_mc.gotoAndPlay(2); it didn't do anything either. I'll try to figure this out then i'll get back to you.
                #2:
                it's going to the frames that i specify, but it's not moving..
                #3:
                Ok, I put the gotoAndPlay on a rollover on a button, and now it's working. I think I have it fixed.. If i have anymore questions i'll post them in here. Thanks
                • 5. Movie Clip array?
                  Capo64 Level 1
                  Here's the next question.. I knew it would be coming soon. I want to create an array of a bunch of different duplicates of bad_mc. Here's what I tried:
                  ma = new Array();
                  for (i=0; i<10; i++){
                  ma = new MovieClip();
                  ma
                  = bad_mc;
                  ma ._x = -2.9;
                  ma
                  ._y = i * 15;
                  }
                  but it doesn't duplicate the movie clip, it just makes ma[9] = bad_mc with the y of 9 * 15
                  • 6. Re: Movie Clip array?
                    Level 7
                    Capo64,

                    >> ma = new MovieClip();

                    Right here. That's a problem. In AS2, this sort of instantiation isn't
                    possible (it is in AS3).

                    >> ma = bad_mc;

                    If that's your MovieClip instance (bad_mc), then that's your instance
                    name. Set your ma variable to bad_mc and you're good to go.

                    var ma:MovieClip = bad_mc;
                    ma.gotoAndPlay(2);

                    >> I have a movie clip in that frame with a stop(); on it's first
                    >> frame, and a tween starting at its second frame. So it should
                    >> start playing the tween when the frame loads, right?

                    If bad_mc's content is fully loaded at the time the above ActionScript
                    is encountered, bad_mc will go to frame 2 (assuming it has a frame 2) and
                    start playing.

                    > Here's the next question.. I knew it would be coming soon.
                    > I want to create an array of a bunch of different duplicates
                    > of bad_mc. Here's what I tried:

                    Okay.

                    > ma = new Array();

                    So far, so good.

                    > for (i=0; i<10; i++){

                    This will make 10 array elements.

                    > ma = new MovieClip();
                    > ma
                    = bad_mc;

                    Okay, these two lines might be something like this ...

                    ma = bad_mc.duplicateMovieClip("newClip" + i,
                    bad_mc._parent.getNextHighestDepth());

                    > ma
                    ._x = -2.9
                    > ma ._y = i * 15
                    > }

                    Your best bet in a situation like this is to check the class entry in
                    the ActionScript 2.0 Langauge Reference for the object in quesiton. Since
                    you're dealing with movie clips, that would be the MovieClip class, which
                    lists all the available properties, methods, and events for any instance.


                    David Stiller
                    Adobe Community Expert
                    Dev blog, http://www.quip.net/blog/
                    "Luck is the residue of good design."


                    • 7. Re: Movie Clip array?
                      Capo64 Level 1
                      Ah, beautiful thanks a lot for the help, i was trying duplicateMovieClip but i didn't really know how to use it. Thanks again