Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 279

Programming actionscript 3.0
Table of Contents

Advertisement

If a fatal error occurs during an attempt to validate the employee XML packet, the error
message is displayed in an Alert component, and the
and
Button component instance are disabled, as the following code shows:
validateBtn
public function showFatalError(error:FatalError):void
{
var message:String = error.message + "\n\n" + "Click OK to end.";
var title:String = error.getTitle();
Alert.show(message, title);
status.text = "This application has ended.";
this.xmlText.enabled = false;
this.validateBtn.enabled = false;
}
If a warning error instead of a fatal error occurs, the error message is displayed in an Alert
component instance, but the TextField and Button component instances aren't disabled. The
showWarningError()
instance. The message also asks the user to decide if they want to proceed with validating the
XML or abort the script. The following excerpt shows the
public function showWarningError(error:WarningError):void
{
var message:String = error.message + "\n\n" + "Do you want to exit this
application?";
var title:String = error.getTitle();
Alert.show(message, title, Alert.YES | Alert.NO, null, closeHandler);
status.text = message;
}
When the user closes the Alert component instance by using either the Yes or No button, the
method is invoked. The following excerpt shows the
closeHandler()
method:
private function closeHandler(event:CloseEvent):void
{
switch (event.detail)
{
case Alert.YES:
showFatalError(new FatalError(9999));
break;
case Alert.NO:
break;
}
}
If the user chooses to abort the script by clicking Yes in the warning error Alert dialog, a
FatalError is thrown, causing the application to terminate.
method displays the custom error message in the Alert component
TextArea component instance
xmlText
showWarningError()
closeHandler()
Example: CustomErrors application
method:
279

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents