Now we will add the backbone to reading and writing, and deleting elements from this array, which is essentially all it is.

bullet_array.push("bullet"+x);

This adds the name of the bullet that is going to be created to the array.

Now find the function fire and insert that line here:

function fire() {
    if (reloaded) {
        x = _root.getNextHighestDepth();
//new line
        bullet_array.push("bullet"+x);
//end new line
        var bullet:MovieClip = _root.attachMovie("bullet", "bullet"+x, x);
        bullet._x = turret._x;
        bullet._y = turret._y;

That`s it for the function fire();

Now lets look at creating enemies to randomly appear on stage.

Draw a red circle and make it into a movieclip and give it an export name of "enemy" (no quotes), if you didn't do this when you created the movieclip go to the library and right-click on the enemy and select properties, or linkage, and select Export for actionscript and make sure the identifier is "enemy".

Now if you have the enemy on stage remove it, and open up the actions panel again. Its time to dynamically attach the enemy, or, multiple enemies.
We will be going to the very end of the script and adding this:

for (x=0; x<10; x++) {
    attachEnemy();
}
function attachEnemy() {
    x = _root.getNextHighestDepth();
    var enemy:MovieClip = _root.attachMovie("enemy", "enemy"+x, x);
    enemy._x = random(Stage.width);
    enemy._y = random(Stage.height);
    enemy.onEnterFrame = function() {
        for (x in bullet_array) {
            if (this.hitTest(_root[bullet_array[x]])) {
                _root[bullet_array[x]].removeMovieClip();
                this.removeMovieClip();
                bullet_array.splice(x,1);
            }
        }
    };
}

Explanation:

The for (x=0; x<10; x++){ just repeats the attachEnemy() function 10 times.

The attachEnemy() function is very similar to the fire() function, the only part that needs to be explained is the enemy.onEnterFrame block.

for (x  in bullet_array) { looks for any movieclip that has the name of one of the values in the bullet_array.

the next line handles if one of those movieclips collides with the enemy, using _root[bullet_array[x]] to know exactly which movieclip it is.

Using the same concept it removes that movieclip, and then itself, and finally removes the bullet movieclip's name from the array.