all groups > flash actionscript > july 2006 >
You're in the

flash actionscript

group:

targeting duplicateMovieClip


targeting duplicateMovieClip jholter
7/20/2006 8:17:53 PM
flash actionscript:
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
Re: targeting duplicateMovieClip zensoldier
7/20/2006 8:26:25 PM
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

Re: targeting duplicateMovieClip jholter
7/20/2006 8:39:04 PM
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


Re: targeting duplicateMovieClip zensoldier
7/20/2006 9:24:10 PM
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?


Re: targeting duplicateMovieClip jholter
7/20/2006 9:56:10 PM
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
Re: targeting duplicateMovieClip blemmo
7/20/2006 10:22:12 PM
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
Re: targeting duplicateMovieClip jholter
7/21/2006 5:00:46 PM
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
AddThis Social Bookmark Button