I've written this spawn code myself, which works... ...kinda.
The problem I'm having is that an enemy doesn't appear when it should. Like if I've told it to spawn a middle and right enemy, sometimes only a middle enemy appears.
This image: http://bit.ly/2iBclJl ...is what it should look like. There's a variable that holds the default monster total which I've set to 2, so two monsters have spawned properly at their positions.
On some occasions though, I get this: http://bit.ly/2iBff0G, which isn't really supposed to happen since the starting total is still set to 2, and only 1 enemy has spawned.
However, I did notice that this issue always occurred whenever two exact enemies are picked, as you can see in the debug list in the top-left of the image.
I'm not brilliant at Actionscript to be honest, so this code may be written completely wrong and is probably a total mess.
var testmonster: placeholder_enem = new placeholder_enem();
var enem_TG: tg_MC = new tg_MC();
var enem_femmelhorn: fhc_MC = new fhc_MC();
var array_testlist: Array = new Array();
var rand_back: MovieClip;
var rand_midd: MovieClip;
var rand_front: MovieClip;
array_testlist.push(testmonster, enem_TG, enem_femmelhorn);
function spwn_back(): void {
get_rand_back();
addChildAt(rand_back, numChildren-4);
rand_back.x = -2355.75;
rand_back.y = 10.35;
MovieClip(root).curr_monster_total++;
MovieClip(root).back_active = true;
back_name();
}
function spwn_middle(): void {
get_rand_midd();
addChildAt(rand_midd, numChildren-3);
rand_midd.x = -2215.70;
rand_midd.y = 70.40;
MovieClip(root).curr_monster_total++;
MovieClip(root).middle_active = true;
middle_name();
}
function spwn_front(): void {
get_rand_front();
addChildAt(rand_front, numChildren-2);
rand_front.x = -2067.70;
rand_front.y = 140.40;
MovieClip(root).curr_monster_total++;
MovieClip(root).front_active = true;
front_name();
}
function get_rand_back(): void {
rand_back = array_testlist[int(Math.random() * array_testlist.length)];
}
function get_rand_midd(): void {
rand_midd = array_testlist[int(Math.random() * array_testlist.length)];
}
function get_rand_front(): void {
rand_front = array_testlist[int(Math.random() * array_testlist.length)];
}
function back_name(): void {
if (rand_back == testmonster) {
MovieClip(root).enem_name_back = "Testmonster";
}
if (rand_back == enem_TG) {
MovieClip(root).enem_name_back = "test_tree";
}
if (rand_back == enem_femmelhorn) {
MovieClip(root).enem_name_back = "Femmelhorn & Crow";
}
}
function middle_name(): void {
if (rand_midd == testmonster) {
MovieClip(root).enem_name_middle = "Testmonster";
}
if (rand_midd == enem_TG) {
MovieClip(root).enem_name_middle = "test_tree";
}
if (rand_midd == enem_femmelhorn) {
MovieClip(root).enem_name_middle = "Femmelhorn & Crow";
}
}
function front_name(): void {
if (rand_front == testmonster) {
MovieClip(root).enem_name_front = "Testmonster";
}
if (rand_front == enem_TG) {
MovieClip(root).enem_name_front = "test_tree";
}
if (rand_front == enem_femmelhorn) {
MovieClip(root).enem_name_front = "Femmelhorn & Crow";
}
}