Hello,
I am trying to set up a simple stage scale listener to center objects on the stage. Though I seem to be doing what all the examples say to do, I am having this error come up when I run this class:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at classes.Interface::Resizer()
at classes.Interface::InterfaceManager()
at classes::CourseManager/init()
at classes::CourseManager()
Seems like the "stage" object is not being recognized correctly. What I don't get is why are all the code samples I look at use "stage" to refer to the Stage class rather than the capitalized "Stage" as the class is actually called? And why is "stage" not being recognized? THANKS!!!
Code:
package classes.Interface {
/**
* @author jkalish
*/
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.EventDispatcher;
import flash.events.Event;
public class Resizer extends Sprite {
//vars
private var interface_mc:MovieClip;
//constructor
public function Resizer(interfaceRef:MovieClip){
trace("***Resizer CONSTRUCT");
//setup stage scale properties
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
//create stage size listening object
stage.addEventListener(Event.RESIZE, stageScaled);
stageScaled();
}
privatefunction stageScaled(e:Event){
//do things
}
}}