<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:validators="com.adobe.cairngorm.validation.*"
layout="vertical"
>
<mx:Script>
<![CDATA[
import sample3.Sample3Model;
[Bindable]
private var model : Sample3Model = new Sample3Model();
]]>
</mx:Script>
<validators:ValidatorGroupSubscriber>
<validators:ValidatorSubscriber
validator="{ model.validatorGroup.firstnameValidator }"
listener="{ firstnameInput }" />
<validators:ValidatorSubscriber
validator="{ model.validatorGroup.lastnameValidator }"
listener="{ lastnameInput }" />
</validators:ValidatorGroupSubscriber>
<mx:Form width="300">
<mx:FormItem label="firstname">
<mx:TextInput
id="firstnameInput"
text="{ model.firstname }"
change="model.firstname = firstnameInput.text" />
</mx:FormItem>
<mx:FormItem label="lastname">
<mx:TextInput
id="lastnameInput"
text="{ model.lastname }"
change="model.lastname = lastnameInput.text" />
</mx:FormItem>
<mx:FormItem
label="FORM VALIDITY"
backgroundColor="{ model.validatorGroup.isValid ? 0xFF00 : 0xFF0000 }"
width="100%">
<mx:Label text="{ model.validatorGroup.isValid }" />
</mx:FormItem>
</mx:Form>
<mx:Button
label="force validation"
click="model.validatorGroup.validate()" />
<mx:Button
label="reset listeners"
click="model.validatorGroup.reset()" />
<mx:Button
label="{ model.validatorGroup.enabled ? 'disable ' : 'enable ' } validatorGroup"
click="model.validatorGroup.enabled = !model.validatorGroup.enabled"
fillColors="{ model.validatorGroup.enabled ? [ 0xFF00, 0xCC00 ] : [ 0xFF0000, 0xCC0000 ] }" />
</mx:Application>