User Guide

Data binding classes (Flash Professional only) 233
Returns
An array, or null.
Description
Method; determines if the data in propertyName is valid based on the property’s schema settings.
The propertys schema settings are those specified on the Schema tab in the Component
Inspector panel.
The method returns
null if the data is valid; otherwise, it returns an array of error messages
as strings.
Validation applies only to fields that have schema information available. If a field is an object that
contains other fields, eachchild” field is validated, and so on, recursively. Each individual field
dispatches a
valid or invalid event, as necessary. For each data field contained by
propertyName, this method dispatches valid or invalid events, as follows:
If the value of the field is null, and is not required, the method returns null. No events
are generated.
If the value the field is null, and is required, an error is returned and an invalid event
is generated.
If the value of the field is not null and the fields schema does not have a validator, the method
returns
null; no events are generated.
If the value is not null and the fields schema does define a validator, the data is processed by
the validator object. If the data is valid, a
valid event is generated and null is returned;
otherwise, an
invalid event is generated and an array of error strings is returned.
Example
The following example shows how to use validateProperty() to make sure that text entered by
a user is of a valid length. You’ll determine the valid length by setting the Validation Options for
the String data type in the Component inspector’s Schema tab. If the user enters a string of
invalid length in the text field, the error messages returned by
validateProperty() are displayed
in the Output panel.
To validate text entered by a user in a TextInput component:
1.
Drag a TextInput component from the Components panel to the Stage, and name it
zipCode_txt.
2.
Select the TextInput component and, in the Component inspector, click the Schema tab.
3.
In the Schema Tree pane (the top pane of the Schema tab), select the text property.
4.
In the Schema Attributes pane (the bottom pane of the Schema tab), select ZipCode from the
Data Type pop-up menu.
5.
Open the Timeline if it is not already open.
6.
Click the first frame on Layer 1 in the Timeline, and open the Actions panel (Window >
Development Panels > Actions).