MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manuel d'utilisateur Page 170

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 184
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 169
170 Additional Migration Issues
Validators
In Flex 1.5, validators were usually triggered in response to an update of the destination of a
data binding expression. You typically assigned the validator to the destination of a data
binding expression, and triggered the validation when the destination of the data binding
expression was updated, as the following example shows:
<!-- Define a data model for storing the phone number. -->
<mx:Model id="userInfo">
<phoneNum>{phoneInput.text}</phoneNum>
</mx:Model>
<!-- Define the PhoneNumberValidator. -->
<mx:PhoneNumberValidator field="userInfo.phoneNum"/>
<!-- Define the TextInput control for entering the phone number. -->
<mx:TextInput id="phoneInput"/>
In Flex 2, validators are triggered by default by the valueCommit event, and you use data
binding to assign it to the interface control rather than to a model. The source property
specifies the name of the control, and the
property property specifies the field of the control
to validate, as the following example shows:
<!-- Define the PhoneNumberValidator. -->
<mx:PhoneNumberValidator id="pnV" source="{phoneInput}" property="text" />
<!-- Define the TextInput control for entering the phone number. -->
<mx:TextInput id="phoneInput"/>
You can also use the validate() method of the validator to trigger a validator
programmatically. All validator classes now include a
validate() method.
CreaditCardValidator constants moved to a new class
The constants that define the type of credit card to validate were moved from the
CreditCardValidator class to a new class named CreditCardValidatorCardType.
The constants were also renamed. In MXML, valid constants values are:
"American Express"
"Diners Club"
"Discover"
"MasterCard"
"Visa"
Vue de la page 169
1 2 ... 165 166 167 168 169 170 171 172 173 174 175 ... 183 184

Commentaires sur ces manuels

Pas de commentaire