# Duplicating Probelm

**URL:** <https://forum.kirupa.com/t/duplicating-probelm/26596>\
**Category:** Uncategorized\
**Created:** [July 24, 2003, 3:23pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596 "2003-07-24T15:23:53Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![BullDog\_Flash](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@BullDog\_Flash](https://forum.kirupa.com/u/BullDog_Flash)\
**Post date:** [July 24, 2003, 3:23pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/1 "2003-07-24T15:23:53Z")

</div>

See I want my MC to get duplicated only at a certain time or at certain points so I added this.

```auto
    if (random(100) == 30) {
        i = i+1;
        duplicateMovieClip(_root.stick, "stick"+i, i);
        this._x -= 5;
    }

```

And that does not seem to wrok.

it doesent add them.

---

<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, 2003, 4:20pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/2 "2003-07-24T16:20:30Z")

</div>

::Bump::

---

<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, 2003, 5:06pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/3 "2003-07-24T17:06:23Z")

</div>

The problem with that code is that the chances of random(100) hitting exactly 30 is a billion to one. You would have to put like Math.floor(random(100)) or Math.round(random(100)); to get a round number, but then your chances of seeing a movieClip duplicate would be a hundred to one. That could be a long time.

If you just want them to randomly show up, you can use this:  
[AS]  
//this code is in a seperate movieClip - I usually make an  
//empty one on the side of the stage for my duplicate codes  
onClipEvent(enterFrame){  
if(getTimer()\>randomTime){  
randomTime=getTimer()+(1000+Math.random()\*10000);  
//that will put your time randomly between 1 sec and 10 sec  
i++;  
//i++ is the same as i=i+1;  
duplicateMovieClip(\_root.stick, “stick”+i, i);  
}  
[/AS]  
Then put your movement code on the original ‘stick’ movieClip:  
[AS]  
onClipEvent(load){  
//where you want ‘stick’ to appear  
\_x=200;  
\_y=200;  
}  
onClipEvent(enterFrame){  
\_x-=5;  
//you may want to delete MCs when they leave the stage too  
if(\_x\<0){  
this.removeMovieClip();  
}  
}  
[/AS]  
There ya go!!

---

<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, 2003, 5:49pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/4 "2003-07-24T17:49:39Z")

</div>

[AS]Math.round(random(100));[/AS]  
You’re a bit confused, Freddy.

The random function returns an integer, you don’t need to round the number. 😛

---

<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, 2003, 6:51pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/5 "2003-07-24T18:51:18Z")

</div>

It does? I thought it was the same as Math.random() ??!! My bad!! Still, the chances are one in 100 - could be a long time. (Right?)  
😕

---

<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, 2003, 6:57pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/6 "2003-07-24T18:57:12Z")

</div>

No whow would I do a Hitest for that

---

<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, 2003, 7:29pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/7 "2003-07-24T19:29:47Z")

</div>

hitTest another movieClip? Or the mouse? Is this for a game?

---

<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, 2003, 8:06pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/8 "2003-07-24T20:06:53Z")

</div>

Yes it is

---

<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, 2003, 8:33pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/9 "2003-07-24T20:33:56Z")

</div>

ne one I need the Duplicated HitTest for MCS hittin another

---

<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, 2003, 11:15pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/10 "2003-07-24T23:15:06Z")

</div>

:;Bump::

Someone please help I have been looking all day just to figure out how to make a HitTest work on a Duplicated MC

---

<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, 2003, 11:36pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/11 "2003-07-24T23:36:10Z")

</div>

I tried learning how hitTest works with a game that I made. The one that I made has some bugs, but the entire post has other peoples suggestions that I never got around to try. I haven’t really gotten into games (yet). At the end of this thread, there’s a game like mine - except it works. So, here it is:

[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=25422&perpage=15&highlight=game%20hitTest&pagenumber=1](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=25422&perpage=15&highlight=game%20hitTest&pagenumber=1)

Good luck!(-:

---

<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 25, 2003, 1:11am UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/12 "2003-07-25T01:11:03Z")

</div>

As much as you helped me and that fourm hlped alot.

But it still dont work.Ill give the fla I am tired of this I tried like 50 times and search 100 times.

Hope maybe the someone can help.

Just if you do please comment the code or if you cant comment it at least tell me on the froums.

Hope ya help.

---

<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 25, 2003, 2:18am UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/13 "2003-07-25T02:18:36Z")

</div>

I played with it, but I can’t figure it out. You may consider starting a new thread with ‘hitTest’ in the title - that way people who know hitTest will look at it. Sorry I couldn’t help more. The code you want is in that zip file that is on page three of the thread I spoke of before - I couldn’t figure it out, it’s beyond me. :\*(

---

<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 25, 2003, 8:31am UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/14 "2003-07-25T08:31:48Z")

</div>

i was just playing around quickly and i got one stick to work and im trying more at the moment

---

<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 25, 2003, 8:36am UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/15 "2003-07-25T08:36:00Z")

</div>

ok now they all work

---

<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 25, 2003, 8:46am UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/16 "2003-07-25T08:46:23Z")

</div>

actually, after a while, it stops working ☹  
i think…

---

<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 25, 2003, 8:48am UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/17 "2003-07-25T08:48:40Z")

</div>

i can fix that easy i just dint really want to it was only a exsample

---

<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 25, 2003, 1:40pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/18 "2003-07-25T13:40:18Z")

</div>

is that what u wanted bulldog?

---

<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 25, 2003, 4:10pm UTC](https://forum.kirupa.com/t/duplicating-probelm/26596/19 "2003-07-25T16:10:08Z")

</div>

Not exactly.

Because  
1.It slows down  
2.It only work for 10 of them
