Hi,
May try this example (Requires an Alert component in the Library, and a button on stage named "myButton" -to launch the Alert-):
AS:
PHP Code:
// IMPORTAN: This script REQUIRES:
// 1) An "Alert" component in the library
// 2) A button on the stage named "myButton" (to launch the Alert)
import mx.controls.Alert;
// USE this button to launch the Alert
myButton.onRelease=function(){
showPopUp() // Launch the Alert window
}
function showPopUp(){
myAlert=mx.controls.Alert.show("Hello there", "Test Alert", Alert.CANCEL |Alert.OK)
myAlert.setSize(300,120)
myAlert.closeButton=true // Add a small close but (x) at the top right of window
myAlert.addEventListener("click", HandleEvent);
}
function HandleEvent(evt:Object){
var ButtonID=evt.detail
if (ButtonID==Alert.CANCEL){
trace("CANCEL clicked")
} else if (ButtonID==Alert.OK){
trace("OK clicked")
} else{ // When the small close button on window clicked
trace("The small Button (x) clicked")
evt.target.deletePopUp();
}
}
trace('NOTE: Need a button on stage named "myButton"')
See the output window for the events when click the Alert buttons..
Regards!
Kostas