<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
public function checkPassword():void
{
if(password.text.length <= 0)
{
Alert.show("请输入密码!");
}
else if(password.text.length < 6)
{
Alert.show("密码太短,请重新输入!");
}
else if(password.text.length > 20)
{
Alert.show("密码太长,请重新输入!");
}
else
{
Alert.show("输入正确!");
}
}
]]>
</fx:Script>
<mx:VBox width="100%" height="100%">
<s:Group width="100%" height="100%">
<s:layout>
<s:VerticalLayout />
</s:layout>
<s:TextInput id="password"/>
<s:Button label="检查密码" click="checkPassword()"/>
</s:Group>
</mx:VBox>
</s:Application>