There’s a behavior all my TitleWindows share: they’re gentle.
With it I mean that they all should have a closeButton that gives the user the option to leave, to quit whatever he/she is doing.
So, I’m sharing my GentleTitleWindow class:
Please be aware that, if you use some AS properties as MXML entries, like <transitions> and <states>, as youre using a particular name space (in this published class is com.utils) you should change it for all your properties as well, like: instead <mx:states> use <ns1:states>
/****************************/
[code lang="actionscript"] package com.utils{import mx.containers.TitleWindow;
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
public class GentleTitleWindow extends TitleWindow{
private var _titleMessage:String;
private var _message:String;
public function GentleTitleWindow(){
super();
showCloseButton=true;
this.addEventListener(CloseEvent.CLOSE, removeMe);
}
public function set titleMessage(value:String):void{
_titleMessage=value;
}
public function set message(value:String):void{
_message=value;
}
private function removeMe(evt:CloseEvent):void{
var title:String=_titleMessage?_titleMessage:"Atenção";
var msg:String=_message?_message:"Esta janela será fechada";
Alert.show(msg,title, Alert.OK|Alert.CANCEL, this, alertClickHandler);
}
private function alertClickHandler(event:CloseEvent):void{
if (event.detail==Alert.OK){
PopUpManager.removePopUp(this);
}
}
}
}[/code]




Recent Comments