I need help/opinion on something. I built a GlobalStage class which is a singleton that allows me to have a global stage variable. I have tried a few ways and maybe its due to my lack knowledge working with singletons. But is it possible to have a method inside the singleton to handle the stageAlign, scaleMode and the other stage properties?
At the bottom is a piece of my class, but I would like to have this singleton control all the stage properties in addition to allow me to have a global stage variable.
Anytime I trace "stage" inside the singleton it comes up null? I don't have to use a singleton but I felt it would be appropriate for what I was trying to accomplish.
ActionScript Code:
public static function get instance():GlobalStage
{
if( _instance == null )
{
constructorLocked = false;
_instance = new GlobalStage();
constructorLocked = true;
}
return _instance;
}
public function get stage():Stage
{
return _stage;
}
public function set stage( value:Stage ):void
{
if( value != null )
{
_stage = value;
}
else
{
value = null;
}
_stage = value;
}
I'm going to eat your brain and gain your knowledge.