Flex Framework – Alert Box Example
Aim:
Alert box is dialog box that appears on window with some message. Alert Box is referred to as pop-up window.
Alert is class that is defined inside the mx:controls package. The pop-up window appears when show () method of the Alert Class is called.
Step 1:
Create Project named AlertPro
Open Flash Builder 4
File--New—Flex Project
< ?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:Script >
< ![CDATA[
import mx.controls.Alert;
import mx.controls.Text;
private function display(event:Event):void
{
Alert.show(tnum.text,"Result");
}
]] >
< /fx:Script >
< mx:Panel title="Alret Box Example" height="400" width="400" >
< mx:Canvas >
< mx:Label id="num" text="Enter Your Name" x="50" y="50"/ >
< mx:TextInput id="tnum" x="200" y="50"/ >
< mx:Button label="OK" click="display(event);" x="200" y="250"/ >
< /mx:Canvas >
< /mx:Panel >
< /s:Application >
step 3:
Run the application
Step 4:
Alert Box will display with what you have entered in the TextInput components.