Random enemy help

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?