# \[FMX\] duplicating MC's - trying to use function

**URL:** <https://forum.kirupa.com/t/fmx-duplicating-mcs-trying-to-use-function/18090>\
**Category:** flash\
**Created:** [April 13, 2003, 4:42am UTC](https://forum.kirupa.com/t/fmx-duplicating-mcs-trying-to-use-function/18090 "2003-04-13T04:42:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgelston](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/tgelston/32/54_2.png) [@tgelston](https://forum.kirupa.com/u/tgelston)\
**Post date:** [April 13, 2003, 4:42am UTC](https://forum.kirupa.com/t/fmx-duplicating-mcs-trying-to-use-function/18090/1 "2003-04-13T04:42:21Z")

</div>

Hello,  
I have two small dots (stars) that I want to duplicate. I have created a function-

//Make stars function  
function makeStars() {  
duplicateMovieClip(\_root.starOne, “star”+b, b);  
b++;  
duplicateMovieClip(\_root.starTwo, “starTwo”+c, c+300);  
c++;  
}  
I placed the function on a blankMC in the onClipevent (load) section. In the onClipEvent (enterFrame) I have placed a setinterval command-

//run the make stars function  
setInterval(makeStars, 8000);

Now this waits 8 seconds and then creates a massive amount of duplicated stars - more than I want. I had just put the duplicate movie bit in a movie every couple of frames and that did what I wanted but I am trying to challenge myself and use functions and code. I am sure there is a better way to get what I want done - any suggestions?

Thank You,  
Tobias  
[http://www.gelstoncafe.com](http://www.gelstoncafe.com)

---

<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:** [April 13, 2003, 5:48am UTC](https://forum.kirupa.com/t/fmx-duplicating-mcs-trying-to-use-function/18090/2 "2003-04-13T05:48:36Z")

</div>

put an end to the code when you reach the number of starts you want. One way would be to check for the value of b, or c…when you reach that value… kill the function

---

<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:** [April 13, 2003, 8:09pm UTC](https://forum.kirupa.com/t/fmx-duplicating-mcs-trying-to-use-function/18090/3 "2003-04-13T20:09:30Z")

</div>

Ooops I didnt fully explain what I am trying to achieve–  
I want these stars to continue duplicating becuase the move off the stage - it is a scrolling starfield.

What I think is happening is the code waits 8 seconds to be triggered and then is triggered everyframe - that is why it gets overloaded - how do I set it up so every 8 seconds the duplicate function is run?

Thanks,  
Tobias
