# duplicateMovieClip inside another

**URL:** <https://forum.kirupa.com/t/duplicatemovieclip-inside-another/761>\
**Category:** flash\
**Created:** [July 29, 2002, 10:21am UTC](https://forum.kirupa.com/t/duplicatemovieclip-inside-another/761 "2002-07-29T10:21:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbk](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@mbk](https://forum.kirupa.com/u/mbk)\
**Post date:** [July 29, 2002, 10:21am UTC](https://forum.kirupa.com/t/duplicatemovieclip-inside-another/761/1 "2002-07-29T10:21:28Z")

</div>

is it in any way possible to duplicate a movieClip inside another movieClip ?

eg. \_root.mClip1.duplicateMovieClip("\_root.mClip2.newClip",100);

where mClip1 and mClip2 are already existing movieclips.

and another thing.  
for some reason the onData event won’t work in the following piece of code. anyone knows why ?

mClip1.duplicateMovieClip(“mClip2”,100);

eval(“mClip2”).onData = function(){  
trace(“blablabla”);  
}

John

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2002, 12:09pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-inside-another/761/2 "2002-07-29T12:09:24Z")

</div>

Hi John,

Assuming you’ve got that code in a movie clip, and that movie clip is loading variables or an external movie, it should work okay if you write:

this.onData = function() {  
trace(“blahblahblah”);  
}

On the main timeline, you could write:

\_root.movieClip.onData = function() {  
trace(“blahblahblah”);  
}

-Karen

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2002, 12:37pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-inside-another/761/3 "2002-07-29T12:37:31Z")

</div>

thanx… =)

anyone got a solution to the other problem ? is it possible at all ?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2002, 4:56pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-inside-another/761/4 "2002-07-29T16:56:15Z")

</div>

i was trying to do this and was unable to find a solution _except_ that a duplicated clip will be created in the same timeline as the original.

if you can put your original in the same timeline you want the duplicates to appear, you should be all right.

if you find a way to change the timelines, let us know! ; )

if attachmovie will serve your purpose, i think you’ll find it’s a little more flexible.

btw, duplicating a clip won’t fire an onData event, there’s no loading going on, just processing. did you want that code to run after duplication, or are you loading variables into it later on?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 30, 2002, 2:28am UTC](https://forum.kirupa.com/t/duplicatemovieclip-inside-another/761/5 "2002-07-30T02:28:27Z")

</div>

yup that’s rite, the onData event is supposed to fire later when i load some  
data to the Clip.

but now im confused… the onData event fires properly on my office comp. but for some reason nothing happens at my comp at home. at home i’m runnin XPpro, at the office win98. tough i haven’t tested the same piece of code on both comps. but will do that today. betta not be sum compatibility prob.

last nite i found yet another prob with flash.

scenario:  
mClip1 and mClip1.imageClip are existing movieClips where  
imageClip are .is a child of mClip1

so lets say i do a

for (i=1; i\<=5; i++){  
mClip1.imageClip.duplicateMovieClip(“imageClip” add i,i);  
eval(“mClip1.imageClip” add i).loadMovie(“whatever.swf”);  
}

which would give the following structure

mClip1.imageClip - empty  
mClip1.imageClip1 - loaded whatever.swf  
mClip1.imageClip2 - loaded whatever.swf  
mClip1.imageClip3 - loaded whatever.swf  
mClip1.imageClip4 - loaded whatever.swf  
mClip1.imageClip5 - loaded whatever.swf

and then later do a  
mClip1.duplicateMovieClip(“newClip”,100);

noting gets duplicated… well atleast not the data i just loaded.

now the structure is:  
mClip1.imageClip - empty  
mClip1.imageClip1 - loaded whatever.swf  
mClip1.imageClip2 - loaded whatever.swf  
mClip1.imageClip3 - loaded whatever.swf  
mClip1.imageClip4 - loaded whatever.swf  
mClip1.imageClip5 - loaded whatever.swf  
newClip.imageClip - empty

what i’m trying to accomplish is a image “preloader” that  
loads all the data i will be using at the beginning.

does anyone know if Flash stores loadMovie data in the cache ?  
so the next time i use loadMovie with the same parameters  
it will read from the cache instead.

thanx for your comment sbeener, i’ll see what that  
attachMovie command can do…

John
