Adding MC's to stage and moving them around

Hi there!

I’m working on a project where I want to add several instances of a movieclip from the library to the stage and making them move around randomly within the stage boundaries. Preferably bouncing them around on the edges.

So far I’ve managed to control how many I add and at random positions, but I can’t figure out the movement I want. Now they just fall diagonally while rotating. I would also like to add them one at a time, say add another MC to the stage every second.

I’ve found a lot of sources online, but they’re all just sort of what I want, and I can’t figure out how to stitch them together.

Any help would be great, thanks!

The Class name of the MC I have is “enemy_mc”. And here is what I’ve written so far:


// Add enemies
var Enemies : Array = new Array();

function createenemy() : void {    
var enemy : enemy_mc = new enemy_mc();   
enemy.x = Math.random() * 600; // randomly position enemy x    
enemy.y = Math.random() * 920; // randomly position enemy y    
addChild(enemy);    
Enemies.push(enemy); // add the enemy onto the list
}

function enemyMove(event:Event) : void
{    
// move all of the Enemies in the Enemies list    
for each(var enemy : enemy_mc in Enemies) {        
enemy.y += 1;        
enemy.x += 1;        
enemy.rotation += 5;    
}    
}
addEventListener(Event.ENTER_FRAME, enemyMove);
// creates 4 enemies
createenemy();
createenemy();
createenemy();
createenemy();