# Random enemy help

**URL:** <https://forum.kirupa.com/t/random-enemy-help/209872>\
**Category:** Uncategorized\
**Created:** [December 12, 2006, 11:45pm UTC](https://forum.kirupa.com/t/random-enemy-help/209872 "2006-12-12T23:45:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cnboy0212](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@cnboy0212](https://forum.kirupa.com/u/cnboy0212)\
**Post date:** [December 12, 2006, 11:45pm UTC](https://forum.kirupa.com/t/random-enemy-help/209872/1 "2006-12-12T23:45:09Z")

</div>

I am making a airplane shooting game,and i got stuck on the random enemy part,i have no idea where to put the code,or how to make it move

here are my codes:

var enemy = 5;

function newEnemy(){  
for(i=0;i\<enemy;i++){  
attachMovie(“enemy”,“enemy”+i,i);  
\_root[“enemy”+i].\_x = (Math.random()\*410) + 20;  
\_root[“enemy”+i].\_y = 0;  
}  
}

i have no idea where to put these codes,i tried on onEnterFrame = function(),but the \_x of the enemy just keep changing every frame,any idea of how to fix it?
