1120: Access of undefined property stage.
Hello,
I'm getting this error: 1120: Access of undefined property stage, in my document class.On the two lines where i commented.
I'm attempting to get an array from the main timeline. Pass it through a function which then adds objects to the stage depending what number is in the array.
my Document class:
package {
import flash.display.MovieClip;
import flash.display.Stage;
public class Levelcreator extends MovieClip{
public function Levelcreator() {
// constructor code
}
public static function getArray(levelArray:Array):void {
for(var i:uint = 0; i < 6; i++){
switch (levelArray){
case 0:
var grid_mc:Grid = new Grid;
grid_mc.x = (40*i) + 60;
grid_mc.y = 60;
stage.addChild(grid_mc);//error here
break;
case 1:
var house_mc:House = new House;
house_mc.x = (40*i) + 60;
house_mc.y = 60;
stage.addChild(house_mc);//error herebreak;
}
}
}
}
}
then on the maintime I'm trying to pass an array to this with:
Levelcreator.getArray([0, 1, 0, 0, 1, 0]);
I cant figure out what I'm doing wrong here. Help would be much appreciated. Thank you.