I have a program where I created a singleton class for the stage so I can access it in my other classes.
I have a few other symbols which have text in them, so will need to have the text modified in the code.
My problem is that whenever I use TLF text instead of Classic Text, any of my classes that reference the singleton stage class get a "TypeError: Error #1009: Cannot access a property or method of a null object reference."
I have previous programs that work fine with TLF text but this is the first time I have used a singleton class for the stage so my guess is it involves that somehow.
I have tried a few solutions in other posts I've seen for related problems (such as publish settings) but so far nothing has worked.
Below is where the first error occurs:
// Constructor
public function Zoom(object:MovieClip) {
// Set the stage
stage = StageManager.instance.stage;
// Set the zoom object
zoomObject = object;
// Add event listener for the mouse wheel
stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseZoom); // ERROR OCCURS HERE
if (Controls.instance.controls.zoomInBtn && Controls.instance.controls.zoomOutBtn) {
Controls.instance.controls.zoomInBtn.addEventListener(MouseEvent.CLICK, zoomIn);
Controls.instance.controls.zoomOutBtn.addEventListener(MouseEvent.CLICK, zoomOut);
}
}
Here is the singleton class:
package {
import flash.display.Stage;
// Singleton class so any other classes can access the stage.
public class StageManager {
// Publicly accessible singleton instance
public static var instance:StageManager = new StageManager();
private var m_stage:Stage;
// Getters and Setters
public function set stage(stg:Stage):void {
m_stage = stg;
}
public function get stage():Stage {
return m_stage;
}
}
}