Fixed and working
Small changes were made to both the Main.as and Enemy.as as follows:
Main.as
The changes made here were to the statement of defining the enemy. It was
enemy = new Enemy(stage, xPos, yPos);
I removed the stage
argument but kept the two variables xPos
and yPos
and made it a variable.
var enemy:Enemy = new Enemy(xPos, yPos);
I also removed where I called the spawnPos()
function.
Enemy.as
I moved the spawnPos()
function from Main.as to here and called it in the constructor code so it's only run when the enemy
varible is.
I then amended the class definition and added the arguments I wanted to be passed
public function Enemy(xPos : Number, yPos : Number)