Monday, December 19, 2011

Custom Alert Message in Flex 4.5

The Alert control is a pop-up dialog box that can contain a message, a title, buttons (any combination of OK, Cancel, Yes, and No) and an icon. The Alert control is modal, which means it will retain focus until the user closes it.
Import the mx.controls.Alert class into your application, and then call the static show() method in ActionScript to display an Alert control. You cannot create an Alert control in MXML.
The Alert control closes when you select a button in the control, or press the Escape key.




Here is the Code for the Alert Message:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
  xmlns:s="library://ns.adobe.com/flex/spark" 
  xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Style source="PopUpWindow.css"/>

<fx:Script>
<![CDATA[
import mx.controls.Alert;
protected function button1_clickHandler(event:MouseEvent):void
{
Alert.yesLabel="Flex is Awesome";
Alert.noLabel="I am not Agree !";
Alert.buttonWidth=120;
Alert.show("Flex 4.5 is Awesome ....","Flex Message",(Alert.YES|Alert.NO));

}
]]>
</fx:Script>

<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Button x="216" y="182" label="Show Alert Message" click="button1_clickHandler(event)"/>
</s:Application>

Css:

/* CSS file */
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";


global
{
font-family: Georgia;
font-size: 14;
color: #762C2C;
}



1 comment:

  1. All given info was wonderful and it's very helpful for everyone, thank you very much for this post............................Please contact us for More Information Oracle Fusion Financials Training

    ReplyDelete