# Duplicate Mc with delay

**URL:** <https://forum.kirupa.com/t/duplicate-mc-with-delay/116934>\
**Category:** Uncategorized\
**Created:** [July 22, 2004, 4:58pm UTC](https://forum.kirupa.com/t/duplicate-mc-with-delay/116934 "2004-07-22T16:58:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![imbuez](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/imbuez/32/645_2.png) [@imbuez](https://forum.kirupa.com/u/imbuez)\
**Post date:** [July 22, 2004, 4:58pm UTC](https://forum.kirupa.com/t/duplicate-mc-with-delay/116934/1 "2004-07-22T16:58:38Z")

</div>

hey everyone

Just posting bu the off chance that someone might be able to shed some light on my problem.

Refering back to this tutorial [http://www.kirupa.com/developer/actionscript/grid.htm](http://www.kirupa.com/developer/actionscript/grid.htm) im trying to duplicate my mc with a delay of a about 1sec each time. Is this possible, any help would be great.

// code so far  
gridx=50;  
gridy=50;  
num=0;  
for (var i=0;i \< 10;i++)  
{  
for (var j=0;j \< 10;j++)  
{  
dot.duplicateMovieClip(“dot”+num,num);  
mc=this[“dot”+num];  
mc.\_x=gridx_i;  
mc.\_y=gridy_j;  
num++;  
}  
}  
dot.\_visible=0;

Im working on this website [http://www.propcomm.co.uk/anambar](http://www.propcomm.co.uk/anambar) , except ive had to manualy create each circle, just to give you some idea.

Thanks very much inadvance  
Martin//…

[http://www.imbuez.co.uk](http://www.imbuez.co.uk/)

---

<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 22, 2004, 6:49pm UTC](https://forum.kirupa.com/t/duplicate-mc-with-delay/116934/2 "2004-07-22T18:49:37Z")

</div>

why r u using two for-s and you can use one of the for() variables instead of _num_ if you kno what i mean…

---

<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 22, 2004, 6:57pm UTC](https://forum.kirupa.com/t/duplicate-mc-with-delay/116934/3 "2004-07-22T18:57:27Z")

</div>

this should give you a 10 frame delay  
in \_root

> \_root.delay=10;

in the loop, replace mc.\_x= and mc.\_y with this

> mc.delayvar=0;  
> mc.k=i;  
> mc.l=j;  
> mc.onEnterFrame=function(){  
> if(this.delayvar\>=\_root.delay){  
> this.\_x=\_root.grid_this.k;  
> this.\_y=\_root.grid_this.l;  
> } else {  
> this.delayvar+=1;  
> }  
> }

and nevermind about the two loops… 😉 (doh)

---

<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 22, 2004, 6:58pm UTC](https://forum.kirupa.com/t/duplicate-mc-with-delay/116934/4 "2004-07-22T18:58:30Z")

</div>

It’s pretty easy and I could just post one of those why dont you search replies cause this topic gets covered a lot but I’ll save you some time and trouble since this is a help forum…  
Put this in flash  
[AS]  
function delayMyMovies(){  
dot.duplicateMovieClip(“dot”+num,num);  
mc=this[“dot”+num];  
mc.\_x=gridx_i; //you’ll have to figure out the math here to make the locations right  
mc.\_y=gridy_j;// I would suggest using \_root.num somehow  
\_root.num++;  
if(\_root.num\>numberOfMoviesNeeded){ //this is just for cleanup no need to have variables that arent used anymore  
clearInterval(delayDuplicate);  
delete \_root.num;  
}  
}  
delayDuplicate = setInterval(“delayMyMovies”,1000); //this delays one second the 1000 is milliseconds  
[/AS]

If you have any sort of trouble with this let me see your modifications and I will do what I can to help you get it working.  
Good Luck,  
Shawn

---

<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 24, 2004, 12:40pm UTC](https://forum.kirupa.com/t/duplicate-mc-with-delay/116934/5 "2004-07-24T12:40:43Z")

</div>

That im afraid all looks foreign to me. ive pasted it into my movie but i just seem to get the one mc. Is there any chance you could explain what youve written so i could learn please.  
Thanks bruv  
Martin//…

> [@paradox244](#):
>
> It’s pretty easy and I could just post one of those why dont you search replies cause this topic gets covered a lot but I’ll save you some time and trouble since this is a help forum…  
> Put this in flash  
> [AS]  
> function delayMyMovies(){  
> dot.duplicateMovieClip(“dot”+num,num);  
> mc=this[“dot”+num];  
> mc.\_x=gridx_i; //you’ll have to figure out the math here to make the locations right  
> mc.\_y=gridy_j;// I would suggest using \_root.num somehow  
> \_root.num++;  
> if(\_root.num\>numberOfMoviesNeeded){ //this is just for cleanup no need to have variables that arent used anymore  
> clearInterval(delayDuplicate);  
> delete \_root.num;  
> }  
> }  
> delayDuplicate = setInterval(“delayMyMovies”,1000); //this delays one second the 1000 is milliseconds  
> [/AS]
> 
> If you have any sort of trouble with this let me see your modifications and I will do what I can to help you get it working.  
> Good Luck,  
> Shawn

---

<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 24, 2004, 3:15pm UTC](https://forum.kirupa.com/t/duplicate-mc-with-delay/116934/6 "2004-07-24T15:15:02Z")

</div>

i can explain mine 🙂  
when the clip is loaded it sets a variable to zero and adds one to it every frame until it equals your number (\_root.delay) and does it to every mc - simple 😛

---

<div class="post-metadata">

**Author:** ![imbuez](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/imbuez/32/645_2.png) [@imbuez](https://forum.kirupa.com/u/imbuez)\
**Post date:** [July 27, 2004, 8:24am UTC](https://forum.kirupa.com/t/duplicate-mc-with-delay/116934/7 "2004-07-27T08:24:22Z")

</div>

hi uudens, thanks for taking the time to do that. Your explanation makes things alot clearer …  
I still seem to be struggling. here is have my origional code with yours

```auto
 
_root.delay=10; 
gridx=50;
gridy=50;
num=0;
for (var i=0;i < 10;i++)
{
for (var j=0;j < 10;j++)
{
dot.duplicateMovieClip("dot"+num,num);
mc=this["dot"+num];
mc.delayvar=0;
mc.k=i;
mc.l=j;
mc.onEnterFrame=function(){
if(this.delayvar>=_root.delay){
this._x=_root.grid*this.k;
this._y=_root.grid*this.l;
} else {
this.delayvar+=1;
}
} num++;
}
}
dot._visible=0;

 

```

Im pretty sure that what im doing here is way of track, thanks for looking in advance.

Martin//…
