I’m new to Flash and not sure why my new planet object is being considered NULL when I try to set properties to it.
Perhaps I am missing some kind of initialization method I should new the planet in, instead of where I declare my variables?
public class main extends Sprite {
private var game_container:game_container_mc;
private var left,up,right,down:Boolean;
var pt:Point = new Point(303,301);
var myArray:Array = [pt,pt,pt];
private var plan:planet = new planet();
public function main() {
plan.loc.x = 3;
plan.loc.y = 3;
//...etc, error is here^
Error: “TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main()”
Cheers
Here you can see that loc is null & not initialized. So either set it here itself.
Or later in the main function as: