home *** CD-ROM | disk | FTP | other *** search
Wrap
package ENGINE.INTERFACE { import ENGINE.CORE.OGlobal; import flash.display.Stage; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.external.ExternalInterface; public class OApplication extends OWindow { private var iStaged:Boolean = false; protected var iBackground:OBackground; protected var iMenuItem:Array; public function OApplication(param1:String) { iStaged = false; OGlobal.AppName = param1; if(this.stage) { OGlobal.SetDomain(); this.InitStage(); } super(null); if(!this.iStaged) { this.addEventListener(Event.ENTER_FRAME,NotStagedEnterFrame); } } override public function Init() : void { if(!this.stage) { return; } super.Init(); this.iMenuItem = new Array(); this.iStaged = true; this.visible = true; } protected function OnMenuItem() : void { } public function get prMenuItem() : int { return !!this.iMenuItem.length ? this.iMenuItem.pop() : -1; } private function NotStagedEnterFrame(param1:Event) : void { if(!iStaged) { if(!this.stage) { return; } OGlobal.SetDomain(); this.InitStage(); this.Init(); this.removeEventListener(Event.ENTER_FRAME,NotStagedEnterFrame); this.iStaged = true; } } public function set prMenuItem(param1:int) : void { this.iMenuItem.push(param1); } override public function Free() : void { OGlobal.prStage.removeEventListener(Event.DEACTIVATE,OnDeactivate); OGlobal.prStage.removeEventListener(Event.RESIZE,OnResize); this.iMenuItem = null; super.Free(); } public function InitStage(param1:Stage = null) : void { var s:String = null; var b:int = 0; var aStage:Stage = param1; if(Boolean(aStage) || Boolean(this.stage)) { OGlobal.prStage = !!aStage ? aStage : this.stage; } if(!OGlobal.prStage) { return; } OGlobal.prStage.scaleMode = StageScaleMode.NO_SCALE; OGlobal.prStage.align = StageAlign.TOP_LEFT; OGlobal.prStage.quality = StageQuality.BEST; OGlobal.prStage.stageFocusRect = false; OGlobal.Rescale(this); OGlobal.FPS = 60; if(ExternalInterface.available) { s = "function getInternetExplorerVersion() { var rv = -1; if (navigator.appName == \"Microsoft Internet Explorer\") { var ua = navigator.userAgent;" + "var re = new RegExp(\"MSIE ([0-9]{1,}[.0-9]{0,})\"); if (re.exec(ua) != null) rv = parseFloat( RegExp.$1 ); } return rv; }"; b = 0; try { b = ExternalInterface.call(s); } catch(e:Error) { OGlobal.prStage.frameRate = OGlobal.FPS; } if(b > 0) { OGlobal.FPS *= 2; } } OGlobal.prStage.frameRate = OGlobal.FPS; OGlobal.prStage.addEventListener(Event.RESIZE,OnResize); OGlobal.prStage.addEventListener(Event.DEACTIVATE,OnDeactivate); } public function OnResize(param1:Event) : void { this.Free(); this.InitStage(); this.Init(); } public function InitBackground(param1:Array, param2:int = 0) : void { this.iBackground = new OBackground(param1,param2); this.addChildAt(this.iBackground,0); } protected function OnDeactivate(param1:Event) : void { } } }