User Guide

Data binding classes (Flash Professional only) 221
Method summary for the CustomValidator class
The following table lists the methods of the CustomValidator class.
CustomValidator.validate()
Availability
Flash Player 6 (6.0 79.0).
Edition
Flash MX Professional 2004.
Usage
This method is called automatically; you dont invoke it directly.
Parameters
value
The data to be validated; it can be of any type.
Returns
Nothing.
Description
Method; called automatically to validate the data contained by the value parameter. You must
implement this method in your subclass of CustomValidator; the default implementation
does nothing.
You can use any ActionScript code to examine and validate the data. If the data is not valid, this
method should call
this.validationError() with an appropriate message. You can call
this.validationError() more than once if there are several validation problems with the data.
Since
validate() might be called repeatedly, avoid adding code that takes a long time to
complete. Your implementation of this method should only check for validity, and then report
any errors using
CustomValidator.validationError(). Similarly, your implementation should
not take any action as a result of the validation test, such as alerting the end user. Instead, create
event listeners for
valid and invalid events and alert the end user from those event listeners (see
the example below).
Example
The following procedure demonstrates how to create and use a custom validator class. The
validate() method of the CustomValidator class OddNumbersOnly.as determines any value
that is not an odd number to be invalid. The validation occurs whenever a change occurs in the
value of a NumericStepper component, which is bound to the
text property of a
Label component.
Method Description
CustomValidator.validate() Performs validation on data.
CustomValidator.validationError() Reports validation errors.