6 Replies Latest reply on Jul 21, 2006 10:00 AM by jholter

    targeting duplicateMovieClip

    jholter
      I may be loosing my head a little on this one but it seems like it shouldnt be that hard. I am trying to duplicate a movieClip from one MC into another MC a quick example would be if I had two MovieClips "A" & "B" and inside of "A" I had a MovieClip "C".

      now what i would like to do is duplicate "C" from "A" and place it inside "B"

      now im pretty aware of the methods and options available to me but cant seem to figure out a combination that would allow something like this to happen. I cant use AttachMovie or anything like that because the contents of these movieClips will be loaded dynamicaly

      Justen
        • 1. Re: targeting duplicateMovieClip
          zensoldier
          There is no conflict between using attachMovie and loading content dynamically. I do it all the time.

          load your data

          attach your clip

          populate it with the data

          Move on to the next one.
          • 2. Re: targeting duplicateMovieClip
            jholter Level 1
            The restriction I have is that the state of the movieClip that I want to duplicate does not exist in my library if you imagine I have MovieClips "A" and "B" and inside of MovieClip "A" there is MovieClip "C" I will load a image into MovieClip "C" now the problem comes into play

            I need to duplicate MovieClip "C" in its current state with the loaded image into MovieClip "B". so that MovieClip "B" does not get replaced but insted gets a child MovieClip of the duplicated MovieClip.

            Not sure if Im explaining this very clearly if there is anything I can specify please let me know

            • 3. Re: targeting duplicateMovieClip
              zensoldier Level 1
              I took a look at the duplicatMovieClip functionality and it seemed iffy. It says that variables in the original clip will not be carried to the new clip.

              I think I understand what you are after and i think I would still use attachMovie.

              I would create a clip in the library to use for attaching. Then you can target whatever container you want.

              I Understand that you are building the the clip you want with data and what you need to do is to duplicate the clip in whatever state it happens to exist in at the time you want to duplicate it. But, you have the data. Each time you populate a clip with its data, hang on to that data as the seed data for the new clip you are going to create with attachMovie.

              So instead of duplicating to clip in the state its in, save the data you used to cause it to be in the state it is in and use feed that data to the new clip so it assumes the state of the other clip.

              Am I making sense?

              • 4. Re: targeting duplicateMovieClip
                jholter Level 1
                Yes thats making perfect sense I really appreciate your post. The problem Im having is that the "data" im loading is JPG, PNG or SWF and trying to get that "data" into another MovieClip with out having to reload the external assets.

                Thanks again Im starting to wonder if this is possible or not
                • 5. Re: targeting duplicateMovieClip
                  blemmo Level 1
                  Content that was loaded dynamically won't be duplicated by the duplicateMovieClip() method and therefore can't be transferred. Besides that, it's just not possible to duplicate MCs into another parent, only into the parent of the original MC.
                  So as already mentioned, try to use attachMovie() instead. For the loaded content, there are 2 ways:
                  - just load it again, Flash should use the cache if it isn't disabled, so it shouldn't load it from the net again. Or
                  - create a bitmap copy of the loaded content and attach it to another MC. This can duplicate the visual content of your MC, but not the functionality. It will eat some ressources too (32 bits per pixel).

                  import flash.display.BitmapData;
                  var picture:BitmapData = new BitmapData(yourMC._width, yourMC._height);
                  picture.draw(yourMC);
                  yourotherMC.attachBitmap(picture,1);

                  hth,
                  blemmo
                  • 6. Re: targeting duplicateMovieClip
                    jholter Level 1
                    Thanks for the help I guess attachMovie and reloading the content isnt that bad if its coming from the cache I will have to play with it a little to see what kind of delays can pop up before the content shows but anyways thanks again