4 Replies Latest reply on Jun 12, 2006 9:58 AM by ofeet

    moving a movieclip's location

    ofeet
      let's say i have _level0.box1.ball
      I want to move ball into _level0.box2 so it will become _level0.box2.ball

      How do I do this and have ball keep all it's original properties?
        • 1. Re: moving a movieclip's location
          Rothrock Level 5
          You do mean during runtime using ActionScript, right? If so, you don't. You can't reparent a clip. (I hear it is coming with the next version of Actionscript.)

          More importantly why do you want to? There is probably a solution for what you are doing.

          You could export the symbol for Actionscript. Take the instance in box1, copy all its properties, remove/delete/unload the orginal, attachMovie, apply properties.
          • 2. Re: moving a movieclip's location
            ofeet Level 1
            yeah, i want to move it at runtime...

            I'm already doing the thing where i copy all the properties, but it's causing a huge memory leak because the movieclips have objects within objects. What I did was used attachMovie and then copied all the stuff using 'for(var i in mc)' and it would freeze very quickly.

            so I made a loop the rules out anything that's an instance of object or of Function. This process works, but it kinda sucks. also, my for loop doesn't rule in any of the _properties (eg. _x, _yscale, _alpha, etc...). I just wanted to know if there's a more efficient way...

            duplicateMovieClip didn't work either because it makes a copy under the same parent... bah!
            • 3. Re: moving a movieclip's location
              Rothrock Level 5
              Why are you trying to move it to a different parent? There really is little reason to do this. Whatever it is that you are trying to do can probably be done easier if you just think about the problem differently. Really.
              • 4. moving a movieclip's location
                ofeet Level 1
                I did think about it.

                Part of the way object oriented languages work is that you can move objects to different parents when needed. However, the movieclip object can't be moved at run time because of it's run time usage.

                For example, if you have a deck of cards, you would put 52 card objects inside of a deck object. Then you can pass the card objects to the player objects and to the 'table' object. But if the card is always visible on the stage, it's harder to do this because you can't change a movieclips location. Sure you can use wannabe pointers, but then you get screwed on movie depths because of parent movie clips.

                All in all, it's a huge mess and it should be easier, hence why I tried to use the forums.