# AS3 Random Spawning help

**URL:** https://forum.kirupa.com/t/as3-random-spawning-help/326486
**Category:** flash
**Created:** [December 18, 2011, 12:15am UTC](https://forum.kirupa.com/t/as3-random-spawning-help/326486 "2011-12-18T00:15:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Teague01233](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@Teague01233](https://forum.kirupa.com/u/Teague01233)
#### Post date: [December 18, 2011, 12:15am UTC](https://forum.kirupa.com/t/as3-random-spawning-help/326486/1 "2011-12-18T00:15:38Z")

</div>

Hey everyone! 😃

I have enemies spawning randomly in my game and the code below decides where they spawn from.

```auto

function onLoad()
{
    _x = 700;
    _y = Math.random()*300;
    speed = Math.random()*5 + 5;
}

```

It all works fine with my other code but my real question is if there is a way to make my enemies spawn randomly from a movieclip, not just a fixed point on the screen, with the code deciding the random spawn position somewhere along the width of the movieclip.?

Any help would be greatly appreciated! \<3
