flex开发中获取单个控件
直接写他的id即可 比如:
as 源码
var username:TextInput =this.username;
var userpwd:TextInput =this.userpwd;
// TODO Auto-generated method stub
Alert.show("用户名:"+username.text+"密码:"+userpwd.text,"登陆信息");
if(username.text==userpwd.text){
Alert.show("用户名和密码相同!","登陆信息");
}else{
Alert.show("用户名和密码不相同!","登陆信息");
}
mxml 源码
<s:Panel x="45" y="67" width="800" height="600" backgroundColor="#7E8A3E" title="登陆窗口" name="登陆窗口111" >
<s:Label x="105" y="83" width="75" height="35" color="#C80606" fontSize="22"
verticalAlign="middle">
<s:text >用户名</s:text>
</s:Label>
<s:TextInput x="200" y="92" id="username" name="username"/>
<s:Label x="109" y="152" width="84" fontSize="22" text="密 码" />
<s:TextInput x="201" y="152" id="userpwd" displayAsPassword="true"/>
<s:Button id="sub" x="105" y="239" label="登 陆" chromeColor="#38DE0B"
click="sub_clickHandler(event)" fontSize="22"/>
<s:Button x="259" y="235" width="79" id="zc" label="注册" chromeColor="#CCCCCC" fontSize="22"/>
</s:Panel>