# Object placed randomly in an array?

**URL:** <https://forum.kirupa.com/t/object-placed-randomly-in-an-array/303748>\
**Category:** flash\
**Created:** [January 26, 2010, 2:26pm UTC](https://forum.kirupa.com/t/object-placed-randomly-in-an-array/303748 "2010-01-26T14:26:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sg123](https://avatars.discourse-cdn.com/v4/letter/s/8e8cbc/32.png) [@sg123](https://forum.kirupa.com/u/sg123)\
**Post date:** [January 26, 2010, 2:26pm UTC](https://forum.kirupa.com/t/object-placed-randomly-in-an-array/303748/1 "2010-01-26T14:26:48Z")

</div>

I’m building this simple platformer (one level, block graphics, just to get the basics down). I have this array system set up:

```auto
level = new Array();
_root.createEmptyMovieClip("lev", _root.getNextHighestDepth());
level[0] = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
level[1] = new Array(1,1,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,1);
level[2] = new Array(1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,1,0,1);
level[3] = new Array(1,0,0,1,1,0,0,1,0,0,0,1,0,0,0,1,1,1,0,1,1,1,1,1,1);
level[4] = new Array(1,1,0,0,0,1,0,0,0,1,1,1,0,1,0,0,1,1,0,0,0,0,0,0,1);
level[5] = new Array(1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,0,0,1,1,1,1,1,0,0,1);
level[6] = new Array(1,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,0,0,0,0,0,0,0,1,1);
level[7] = new Array(1,1,0,1,1,0,0,0,1,0,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1);
level[8] = new Array(1,0,0,0,0,1,1,0,0,0,1,0,1,1,1,1,0,0,0,1,0,1,0,1,1);
level[9] = new Array(1,0,1,1,0,1,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,1);
level[10] = new Array(1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,1,1,1,1);
level[11] = new Array(1,1,0,0,1,0,0,1,0,0,1,1,0,1,0,1,1,1,0,0,0,0,1,1,1);
level[12] = new Array(1,0,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1);
level[13] = new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);

```

Pretty straight forward, right? The "1"s are the ceiling, walls and floor and the "0"s are the empty spaces for the player to move around.

That’s all fine and good. I have a character set up to move around, jump and fall through this maze, but there’s no point to it. What I want to do is have a “coin” object appear randomly in one of those "0"s. When the character touches the coin, it disappears and reappears in another “0”.

I can’t figure this out, can anyone help?

Thanks!
