<?xml version="1.0"
encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" verticalAlign="top"
horizontalAlign="center"
backgroundGradientColors="[#570A0A, #731F1F]" paddingTop="0"
backgroundGradientAlphas="[1.0, 1.0]">
<mx:Script>
import mx.controls.Alert;
</mx:Script>
<!-- Define model for the
credit card data. -->
<mx:Model id="creditcard">
<card>
<cardType>{cardTypeCombo.selectedItem.data}</cardType>
<cardNumber>{cardNumberInput.text}</cardNumber>
</card>
</mx:Model>
<mx:CreditCardValidator id="ccV"
cardTypeSource="{creditcard}" cardTypeProperty="cardType"
cardNumberSource="{creditcard}"
cardNumberProperty="cardNumber"
trigger="{myButton}" triggerEvent="click"
cardTypeListener="{cardTypeCombo}"
cardNumberListener="{cardNumberInput}"
valid="Alert.show('Validation Succeeded!');"/>
<mx:Panel title="CreditCardValidator Example" layout="vertical" color="0xffffff" borderAlpha="0.15"
paddingTop="10" paddingRight="10" paddingBottom="10" paddingLeft="10" horizontalAlign="center" x="10" y="10">
<mx:Form id="creditCardForm" color="0x323232">
<mx:FormItem label="Card Type">
<mx:ComboBox id="cardTypeCombo">
<mx:dataProvider>
<mx:Object label="American Express" data="American Express"/>
<mx:Object label="Diners Club" data="Diners Club"/>
<mx:Object label="Discover" data="Discover"/>
<mx:Object label="MasterCard" data="MasterCard"/>
<mx:Object label="Visa" data="Visa"/>
</mx:dataProvider>
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Credit Card Number">
<mx:TextInput id="cardNumberInput"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button id="myButton" label="Check Credit"/>
</mx:FormItem>
</mx:Form>
</mx:Panel>
</mx:Application>
No comments:
Post a Comment