# Random object generation

**URL:** <https://forum.kirupa.com/t/random-object-generation/8603>\
**Category:** flash\
**Created:** [November 24, 2002, 11:02pm UTC](https://forum.kirupa.com/t/random-object-generation/8603 "2002-11-24T23:02:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![WobblyFork](https://avatars.discourse-cdn.com/v4/letter/w/e68b1a/32.png) [@WobblyFork](https://forum.kirupa.com/u/WobblyFork)\
**Post date:** [November 24, 2002, 11:02pm UTC](https://forum.kirupa.com/t/random-object-generation/8603/1 "2002-11-24T23:02:14Z")

</div>

I guess this is a little vague, but always worth a shot 🙂

Anyone have a good idea for what kind of script framework I should use to:

1. Make a movieClip appear in a random place (I’ve got this down fine, but…)

2. Make other instances of the movie clip appear in other random places while the first one is still on-screen, but at random intervals?

Keep in mind the basis for this question is that I’m making a game where targets must appear and disappear if not shot, but I want other targets to be able to appear on-screen at the same time if the user hasn’t gotten around to destroying the first, second, etc. yet.

Well, thanks for any suggestions! 🙂

- wobbly

---

<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:** [November 24, 2002, 11:25pm UTC](https://forum.kirupa.com/t/random-object-generation/8603/2 "2002-11-24T23:25:20Z")

</div>

establish a frequency.

nFreq= Math.round(Math.random()\*10)

then use an if statement to check when the value is a number, I used 5.

```php

_root.onEnterFrame = function(){
     nFreq = Math.round(Math.random()*10)
     if(nFreq == 5){
          //
          //Here you would duplicate the movieclip
          //Or attach the MovieClip
          //
     }
}

```

---

<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:** [November 24, 2002, 11:29pm UTC](https://forum.kirupa.com/t/random-object-generation/8603/3 "2002-11-24T23:29:04Z")

</div>

Here:

---

<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:** [November 24, 2002, 11:33pm UTC](https://forum.kirupa.com/t/random-object-generation/8603/4 "2002-11-24T23:33:19Z")

</div>

Replied together, hmm, 4 min difference!

---

<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:** [November 25, 2002, 11:16pm UTC](https://forum.kirupa.com/t/random-object-generation/8603/5 "2002-11-25T23:16:16Z")

</div>

Hey, this is great… you’re all so responsive and helpful 🙂

Jubba, thanks, I learned a new trick 🙂

h88 … I must say, after being on the board a little while, you’re awesome :beam:

Thanks again 🙂

- wobbly

---

<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:** [November 25, 2002, 11:17pm UTC](https://forum.kirupa.com/t/random-object-generation/8603/6 "2002-11-25T23:17:23Z")

</div>

No problem. 🙂
