User Guide
Data binding classes (Flash Professional only) 223
18.
Open the Timeline and select the first frame on Layer 1.
19.
Open the Actions panel.
20.
Add the following code to the Actions panel:
function dataIsInvalid(evt) {
if (evt.property == "text") {
status.text = evt.messages;
}
}
function dataIsValid(evt) {
if (evt.property == "text") {
status.text = "OK";
}
}
textLabel.addEventListener("valid", dataIsValid);
textLabel.addEventListener("invalid", dataIsInvalid);
21.
Save the FLA file as OddOnly.fla to the same folder that contains OddNumbersOnly.as.
22.
Test the SWF file (Control > Test Movie).
Click the arrows on the NumericStepper component to change its value. Notice the message
that appears in the TextArea component when you choose even and odd numbers.
CustomValidator.validationError()
Availability
Flash Player 6 (6.0 79.0).
Edition
Flash MX Professional 2004.
Usage
this.validationError(errorMessage)
Note: This method can be invoked only from within a custom validator class; the keyword
this refers
to the current CustomValidator object.
Parameters
errorMessage
A string that contains the error message to be reported.
Returns
Nothing.
Description
Method; called from the validate() method of your subclass of CustomValidator to report
validation errors. If you don’t call
validationError(), a valid event is generated when
validate() finishes executing. If you call validationError() one or more times from within
the
validate(), an invalid event is generated after validate() returns.