topical media & game development
professional-flex-code-09-SimpleASValidation.mx
professional-flex-code-09-SimpleASValidation.mx
[swf]
flex
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="#FFFFFF" width="300" height="150">
<mx:Script>
<![CDATA[
private function validate():void{
// check for length of 10
if(myText.text.length < 10){
// assign errorString to TextInput
myText.errorString = "This field requires at least 10 characters";
} else {
// remove errorString
myText.errorString = null;
}
}
]]>
</mx:Script>
<mx:Panel title="Simple AS Validate" width="210" height="75">
<mx:HBox width="100%" height="100%" paddingLeft="3" paddingTop="3">
<mx:TextInput id="myText" width="100"/>
<mx:Button label="Validate" click="validate()" />
</mx:HBox>
</mx:Panel>
</mx:Application>
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.