# Placing objects to predefined positions

**URL:** <https://forum.kirupa.com/t/placing-objects-to-predefined-positions/323966>\
**Category:** flash\
**Created:** [July 26, 2011, 12:32pm UTC](https://forum.kirupa.com/t/placing-objects-to-predefined-positions/323966 "2011-07-26T12:32:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timppaface](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@Timppaface](https://forum.kirupa.com/u/Timppaface)\
**Post date:** [July 26, 2011, 12:32pm UTC](https://forum.kirupa.com/t/placing-objects-to-predefined-positions/323966/1 "2011-07-26T12:32:18Z")

</div>

Hello. I am trying to create a script that spawns cubes with one second (30 frames) delay, then places it into one of the 10 predefined positions.

> 

[LEFT]spawnTimer = [COLOR=#cc66cc]0[/COLOR]

```
[COLOR=#000000] **function** [/COLOR] [COLOR=#0066CC]onEnterFrame[/COLOR][COLOR=#66cc66]([/COLOR][COLOR=#66cc66])[/COLOR]
[COLOR=#66cc66]{[/COLOR]

```

spawnTimer += [COLOR=#cc66cc]1[/COLOR];

[COLOR=#b1b100]if[/COLOR][COLOR=#66cc66]([/COLOR]spawnTimer \>= [COLOR=#cc66cc]30[/COLOR][COLOR=#66cc66])[/COLOR]  
[COLOR=#66cc66]{[/COLOR]  
spawnTimer = [COLOR=#cc66cc]0[/COLOR];  
[COLOR=#000000] **var** [/COLOR] cube = [COLOR=#0066CC]\_root[/COLOR].[COLOR=#0066CC]attachMovie[/COLOR][COLOR=#66cc66]([/COLOR][COLOR=#ff0000]“cube”[/COLOR], [COLOR=#ff0000]“cube”[/COLOR]+[COLOR=#0066CC]\_root[/COLOR].[COLOR=#0066CC]getNextHighestDepth[/COLOR]COLOR=#66cc66[/COLOR], [COLOR=#0066CC]\_root[/COLOR].[COLOR=#0066CC]getNextHighestDepth[/COLOR]COLOR=#66cc66[/COLOR][COLOR=#66cc66])[/COLOR];  
cubes.[COLOR=#0066CC]push[/COLOR]COLOR=#66cc66[/COLOR]

cube.[COLOR=#0066CC]\_y[/COLOR] = [COLOR=#cc66cc]150[/COLOR]  
cube.[COLOR=#0066CC]\_x[/COLOR] = [COLOR=#808080]_//Help needed here._[/COLOR]  
[COLOR=#66cc66]}[/COLOR]  
[COLOR=#66cc66]}[/COLOR][/LEFT]

The ten prefined positions are:

10,150  
20,150  
30,150  
And so on… The problem is that I cannot find a way to \*\*RANDOMLY \*\*locate the blocks into these postions so, that only one cube can be in one location.

It would be great if somebody could direct me to the right path. Using Flash CS5.5 with actionscript 2.
