Home Tutorial Flex Flex4 Components Alert Control in Flex4

 
 

Share on Google+Share on Google+
Alert Control in Flex4
Posted on: May 24, 2010 at 12:00 AM
Advertisement
The Alert control is a MX component. It has no Spark component. The Alert control contains a message, icon, title, and buttons.

Alert control in Flex4:

The Alert control is a MX component. It has no Spark component. The Alert control contains a message, icon, title, and buttons. Flex uses the show() method of the Alert classfor open a dialog box.
The Syntax of Alert.show() method is:

public static show(
text:String,
title:String=null,
flags:uint=mx.controls.Alert.OK,
parent:Sprite=null,
clickListener:Function=null,
iconClass:Class=null,
defaultButton:uint=mx.controls.Alert.OK
):Alert

Example:

<?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.events.CloseEvent;

[Embed(source="C:/work/bikrant/flex4component/alert/submit.png")]

[Bindable]

public var icon:Class;

public function alertcontrol(obj:CloseEvent):void{

if(obj.detail==Alert.OK){

lbl.text=txt1.text;

}

}

]]>

</fx:Script>

<s:Panel title="Alert control Example" width="215" height="192">

<s:VGroup x="18" y="16" height="116">

<s:TextInput id="txt1"/>

<s:Button id="btn"

label="Submit"

click='Alert.show("Submitted Successfully", "Alert Message", Alert.OK |

 Alert.CANCEL, this, alertcontrol, icon, Alert.OK);'/>

<s:Label id="lbl" fontWeight="bold"/>

</s:VGroup>

</s:Panel>

</s:Application>

In this example you can see how we can use a Alert control in Flex4.

Output:

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

Advertisement

Related Tags for Alert Control in Flex4:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 24, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com