3.12.创建TitleWindow

3.12.1 问题
我们需要创建一个TitleWindow 组件来显示对话框并在满足一定标准的时候使用PopUpManager 移除该对话框。
3.12.2 解决办法
TitleWindow 组件,继承自Panel,添加了可以为窗口设置标题的功能,同时也为边框提供样式信息。
3.12.3 讨论
PopUpManager.removePopUp(this);
此例中,使用TitleWindow 为应用程序创建一个登陆界面。PopUpManager 类提供PopUpManager.removePopUp 方法使组件可以在屏幕上移除其本身。

这说明TitleWindow 组件是由PopUpManager 添加的。
+展开
-XML
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
borderColor="#0000ffbackgroundAlpha="0.6"
title="Title Windowx="168y="86">

<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.controls.Text;
// A reference to the TextInput control in which to putthe result.
public var loginName:Text;
public var loggedIn:Boolean;
// Event handler for the OK button.
private function returnName():void {
loginName.text="Name entered: " + userName.text;
PopUpManager.removePopUp(this);
}
private function checkUserNameAndPass():void
{
/* Do some processing */
}
/* have this handle the event when the server has logged in */
private function returnValueFromLogin(event:Event):void
{
if(loggedIn)
{
PopUpManager.removePopUp(this);
}e
else
{
successText.text = "User/Pass not recognized";
}
}

]]>
</mx:Script>
<mx:HBox>
<mx:Label text="Username "/>
<mx:TextInput id="userNamewidth="100%"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Password"/>
<mx:TextInput id="passwordwidth="100%"/>
</mx:HBox>
<mx:HBox>
<mx:Button label="Enterclick="checkUserNameAndPass();"/>
<mx:Button label="Cancel"
click="PopUpManager.removePopUp(this);"/>

</mx:HBox>
<mx:Text id="successTextcolor="#ff0000"/>
</mx:TitleWindow>

加支付宝好友偷能量挖...


评论(0)网络
阅读(112)喜欢(0)flash/flex/fcs/AIR