Hey guys,
Not sure if the title of this topic is correct, but what I’m trying to do is store a movieclip inside each array element using a for loop.
However, I have 2 movieclips to choose from and I want the movieclip to be randomly assigned to each element in the array.
Here’s what I have so far but the syntax is obviously wrong:
var enemyArray:Array = new Array();
var randomEnemyNo:int;
var noOfEnemyMC:int = 2;
for(var i = 0; i < 5; i++) {
randomEnemyNo = (Math.floor(Math.random() * noOfEnemyMC) + 1);
enemyArray* = new this["Enemy" + randomEnemyNo + "();"];
}
OUTPUT:
ReferenceError: Error #1069: Property Enemy1(); not found on RandomSpawn and there is no default value.
ReferenceError: Error #1069: Property Enemy2(); not found on RandomSpawn and there is no default value.
RandomSpawn is the name of my project.
I have an “Enemy1” and “Enemy2” movieclip in my Library.
.FLA and .AS attached as a .ZIP.
Can anyone help?