Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 278

Programming actionscript 3.0
Table of Contents

Advertisement

</employee>;
}
The XML packet is later displayed in a TextArea component instance on the Stage. This
allows you to modify the XML packet before attempting to revalidate it.
When the user clicks the Validate button, the
method validates the employee XML packet using the
the Validator class. The following code shows the
public function validateData():void
{
try
{
var tempXML:XML = XML(xmlText.text);
Validator.validateEmployeeXML(tempXML);
status.text = "The XML was successfully validated.";
}
catch (error:FatalError)
{
showFatalError(error);
}
catch (error:WarningError)
{
showWarningError(error);
}
catch (error:Error)
{
showGenericError(error);
}
}
First, a temporary XML object is created using the contents of the TextArea component
instance
. Next, the
xmlText
(com.example.programmingas3/errors/Validator.as) is invoked and passes the temporary
XML object as a parameter. If the XML packet is valid, the
displays a success message and the application exits. If the
threw a custom error (that is, a FatalError, WarningError, or a generic Error occurred), the
appropriate
statement executes and calls either the
catch
showWarningError()
appropriate message in an Alert component to notify the user of the specific error that
occurred. Each method also updates the
message.
278
Handling Errors
validateEmployeeXML()
, or
showGenericError()
status
method is called. This
validateData()
validateEmployeeXML()
validateData()
method in the custom Validator class
Label component instance
status
validateEmployeeXML()
showFatalError()
methods. Each of these methods displays an
Label component instance with a specific
method in
method:
method
,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents