我想做一个用户登入界面,正确登入后,要拿到刚才用户登入时输入的用户名。
主界面: APPlication.mxml
[code="xml"]<?xml version="1.0" encoding="utf-8"?>
creationComplete="initFrame()">
mx:Script
<![CDATA[
import mx.controls.Alert;
public function initFrame():void{
(new User()).showModal();
}
]]>
</mx:Script>
/mx:Application[/code]
登入框:User.mxml
[code="xml"]<?xml version="1.0" encoding="utf-8"?>
xmlns:flexmdi="flexmdi.containers.*" title="会员登入" layout="absolute" width="336" height="232"
minButtonVisible="false" maxButtonVisible="false" closeButtonVisible="false" creationComplete="initUser()" fontSize="20" borderColor="#FF0000">
mx:Script
<![CDATA[
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.events.CloseEvent
public function initUser():void {
}
public function checkUser():void {
if(uname.text=="" || upass.text==""){
Alert.show("请输入用户名和密码",null,1);
}else if(uname.text == upass.text){
// do something and then close the login frame
closeWindow();
// (new MemberLogin()).showModal();
} else {
Alert.show("用户名或者密码不正确", null, 1);
}
}
public function isQuit():void{
Alert.show("Seriously? Close it?", null, 3, null, handleAlertResponse);
}
public function handleAlertResponse(event:CloseEvent):void
{
if(event.detail == mx.controls.Alert.YES)
{
closeWindow();
}
}
]]>
</mx:Script>
<flexmdi:MDICanvas id="mdiCanvas" horizontalScrollPolicy="off" verticalScrollPolicy="off"
width="296" height="168" backgroundColor="#FFFFFF" backgroundAlpha="0" x="10" y="10">
<mx:Label x="23" y="28" text="会员号码:" width="97" fontSize="16"/>
<mx:Label x="23" y="75" text="密码:" fontSize="16" width="74"/>
<mx:TextInput id="uname" x="128" y="26" fontSize="16"/>
<mx:TextInput id="upass" x="128" y="73" fontSize="16" fontFamily="Times New Roman" width="160"/>
<mx:Button id="uexit" x="160" y="130" label="放弃" click="isQuit()" themeColor="#18FF00" fontSize="16"/>
<mx:Button x="50" y="130" label="登入" click="checkUser()" themeColor="#18FF00" fontSize="16"/>
</flexmdi:MDICanvas>
[/code]
我想在主界面中拿到用户输入的用户名,这里是User.mxml中的uname这个的Text值。
所以我想知道怎么样才可以把Text值传到 APPlication.mxml中。
可以的话,麻烦你举个例子啊,谢谢