在Air的开发过程中,有时会遇到要设置值,比如说要设置父窗体的内容。这样可以使用TitleWindow来实现。
将Title对象窗体中的内容传递到父窗体中。
首先我们加载一个TitleWindow
<s:TitleWindow x="97" y="10" width="336" height="200" id="tw" title="请设置欢迎词" enabled="true">
<mx:VBox width="334" height="115">
<mx:HBox>
<mx:Label text="请编辑欢迎词内容:" width="131"/>
<mx:TextArea id="txtContent" text="热烈欢迎" />
</mx:HBox>
<mx:HBox>
<mx:Label text="请设置欢迎词字体大小: " width="131" />
<mx:TextInput id="txtFont" text="20" />
</mx:HBox>
<mx:HBox>
<s:Button id="setButton" label="设置" click="setButton_clickHandler(event)" />
<s:Button id="cancelButton" label="取消" click="cancelButton_clickHandler(event)"/>
</mx:HBox>
</mx:VBox>
</s:TitleWindow>
然后,我们要一开始就加载这个TitleWInodw,所以默认为visible=true;
加后我们设置一个textField的值和它的值性
protected function setButton_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
content=this.txtContent.text;
font=this.txtFont.text;
if(content.length ==0 || font.length == 0){
Alert.show("请输入文本框中的值","温馨提示");
return;
}
welcomeInfo=content;
txtWelcomeInfo.setStyle("fontSize",10);
tw.visible=false;
}
protected function cancelButton_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
tw.visible=false;
}
其中:
textWelcomeInfo为:
<s:TextInput x="305" y="221" id="txtWelcomeInfo" text="{welcomeInfo}" fontSize="23"/>