package basement_core { import flash.display.DisplayObject; import flash.display.Loader; import flash.display.MovieClip; import flash.events.Event; import flash.events.ProgressEvent; import flash.utils.getDefinitionByName; public class DocumentBase extends MovieClip { // Data // Display Objects // Properties protected var configLoaded:Boolean; protected var contentLoaded:Boolean; public function DocumentBase() { super(); stop(); this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler); this.loaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler); } protected function init():void { var Symbol:Object = getDefinitionByName("package.Class"); var content:DisplayObject = new Symbol(); this.addChild(content); } // Helpers protected function isReady():void { if(this.contentLoaded){ this.gotoAndStop("READY"); this.init(); } } // Log protected function log(msg:String):void { trace("[DocumentBase] "+msg); } // Handlers protected function onProgressHandler(e:ProgressEvent):void { log("PROGRESS: "+e.bytesLoaded +"/"+e.bytesTotal); } protected function onCompleteHandler(e:Event):void { log("** SWF COMPLETE **"); this.contentLoaded = true; this.isReady(); this.removeEventListener(ProgressEvent.PROGRESS, onProgressHandler); this.loaderInfo.removeEventListener(Event.COMPLETE, onCompleteHandler); } } }