Explicitly handling component validation events
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import flash.events.Event;
private var currentTextColor:Object;
private function myCreationComplete(eventObj:Event):void {
currentTextColor = getStyle('color');
}
private function handleInvalidVal(eventObject:Event):void {
setStyle('color', "red");
}
private function handleValidVal(eventObject:Event):void {
setStyle('color', currentTextColor);
}
</mx:Script>
<mx:PhoneNumberValidator source="{phoneInput}" property="text" />
<mx:TextInput id="phoneInput"
initialize="myCreationComplete(event);"
invalid="handleInvalidVal(event);" valid="handleValidVal(event);" />
<mx:TextInput id="zipInput" />
</mx:Application>
Related examples in the same category