Added to Stage Event
Posted on 27. Mar, 2009 by thornyeternity in ActionScript 3 Snippets
Prevent Error #1009 – stage property not accessible (null) in loaded swf files after calling from a preloader.
Thanks to:
who explains it well and is less ratty and petulently ‘clever’ as some people on forums.
(In Initialiser function)
public function ImpactVisualHome(){
trace(“main class started”);
if (stage){
onAddedToStage();
} else {
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
}//init
private function initApp():void{
//do all things it needs to once it has registered the stage
}//initApp
private function onAddedToStage(event:Event=null):void {
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
initApp();
}


