User Guide
CustomValidator.validationError() 219
15. In the Schema Attributes pane, select Custom from the Data Type pop-up menu.
16. Double-click the Validation Options field in the Schema Attributes pane to open the
Custom Validation Settings dialog box.
17. In the ActionScript Class text box, enter OddNumbersOnly, which is the name of the
ActionScript class you created previously. Click OK.
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.