老规矩,先贴代码:
<?xml version="1.0" encoding="utf-8"?> <mx:Window xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="800" height="600" title="oliwen博客" fontFamily="Arial" fontSize="12" borderColor="#F6EAEA" cornerRadius="10" xmlns:display="flash.display.*" creationComplete="init()" backgroundAlpha="0.0" xmlns:Attribute="mapEdit.windowView.Attribute.*" > <mx:Script> <![CDATA[
private static var Instance:ThisClass; [Bindable] private var isOpen:Boolean; private function init():void { this.addEventListener(Event.CLOSING,closeer); } /**获取唯一实例*/ public static function getInstance():ThisClass { if(Instance == null) Instance = new ThisClass; return Instance; } public function opening():void { if(isOpen) this.restore(); else{ this.open(); isOpen=true; } this.alwaysInFront = true; } private function closeer(e:Event):void { Instance = null; clear(); } ]]> </mx:Script> </mx:Window>
原理:用的就是单例模式。(反正我是在帮助中没找到相关的属性设置,无赖,想办法实现了一个)。。同时也
实现了当窗口最小化的时候在点击按扭打开这个窗口的时候会自动还原并在最前面显示的功能.
ThisClass.getInstance().opening(); //打开窗体
ThisClass.getInstance().move(x,y); //要控制窗体在桌面上的显示位置,就用这个自带的方法. |