PDA

View Full Version : Setting buttonMode To True On Alert


brixel
04-09-2008, 01:27 PM
Hey guys,

Hoping this is an easy one. I can't seem to find out how to set the buttonMode of the buttons in an Alert prompt to true. It looks like buttonMode is inherited according to the docs, but not seeing how to enable it. Thanks.

kifah
04-09-2008, 04:44 PM
Hello,

try this :

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.controls.Alert;
private function init():void
{
var myAlert:Alert=new Alert();
myAlert.buttonMode=true;
myAlert.useHandCursor=true;
myAlert.title="";
myAlert.text="Hi";
addChild(myAlert);
myAlert.addEventListener(CloseEvent.CLOSE,function ():void
{
try{removeChild(myAlert);}catch(ex:Error){}
});
}
]]>
</mx:Script>
</mx:Application>



the most important thing is to add Close event listener ....

Regards
Kifah

brixel
04-09-2008, 06:10 PM
Hey Kifah,

Thanks, that does work. I was wondering if there was a way to make it part fo the Alert class itself though, so one could just use the Alert as designed, but set a parameter before hand like, Alert.buttonMode = true, before calling show.

kahuja
04-09-2008, 09:31 PM
I was wondering if there was a way to make it part fo the Alert class itself though

You can extend the Alert class and have your own Alert.