This is what my code looks like:

---------------------------------------------------------------------------------------------------

private static var _alertUI:GHAlertUI = new GHAlertUI();
public static const CUSTOM_EVENT:String = "GHAlertEvent";

public function GHAlert(){
}
                
public static function show( message:String, title:String=null, 
buttons:Array=null, closeHandler:Function=null ):void {
_alertUI = GHAlertUI( PopUpManager.createPopUp( Application.application as 
DisplayObject, GHAlertUI, true ) );
PopUpManager.centerPopUp( _alertUI );

if( closeHandler != null ) _alertUI.addEventListener( CUSTOM_EVENT, 
closeHandler );

//Buttons
var button:GHAlertButton;

if( !buttons || buttons.length == 0 ){
button = new GHAlertButton();
button.labelText = 'OK';
button.addEventListener( MouseEvent.CLICK, buttonClickHandler );
_alertUI.buttons.addChild( button );
}

else {
for( var i:int=0; i<buttons.length;i++){
button = new GHAlertButton();
button.labelText = buttons[i].toString().toUpperCase();
button.addEventListener( MouseEvent.CLICK, buttonClickHandler );
_alertUI.buttons.addChildAt( button, 0 );
}
}

}

private static function buttonClickHandler( event:MouseEvent ):void {
_alertUI.dispatchEvent( new GHAlertEvent( CUSTOM_EVENT, 
event.currentTarget.labelText ) );
PopUpManager.removePopUp( _alertUI );
}

---------------------------------------------------------------------------------------------------

So basically if I do GHAlert.show(....) it works fine, however, if I do 
GHAlert.show(....) twice, the only one that works is the top, so if I close the 
top the buttons don't work on the bottom, almost like the events aren't firing.

Thanks for any help!

Reply via email to