flex中创建弹出窗口,并传值

在flex页面中首先创建一个弹出窗口,代码如下:

<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
title="title" horizontalCenter="0" verticalCenter="0" backgroundColor="white"
chromeColor="#5CACEE" close = "removeWindow()" cornerRadius="5"
width="600" height="440" creationComplete="init()">
<fx:Declarations>
</fx:Declarations>
<fx:Style> @namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
@namespace component "com.xyw.sys.custom.component.*";
@namespace skin "com.xyw.sys.custom.skin.*";
.myLabel
{
fontStyle:italic;
fontWeight:bold;
color:#A020F0;
fontFamily:微软雅黑;
} </fx:Style>
<fx:Script>
<![CDATA[import com.model.VD3;import mx.collections.ArrayCollection;
import mx.collections.ArrayList;
import mx.controls.Alert;
import mx.controls.DateField;
import mx.managers.PopUpManager;import mx.rpc.events.ResultEvent; public var cerDataGrid:ArrayCollection;
public var vd3:VD3;
private function init():void
{
//init your function
}
private function removeWindow():void
{
PopUpManager.removePopUp(this);
}
]]>
</fx:Script>
</s:TitleWindow>

2.然后在主页面中调用它:用到如下函数

 public function myFunction(event:MouseEvent):void
{
if(this.vD3 == null){
Alert.show("请选择要操作的行");
return;
}else{
var window:detial = new detial();
window.vd3 = this.vD3;// 要传入的model
PopUpManager.addPopUp(window,this);
var x:Number = (this.parentApplication.mdiCanvas.width - window.width) / 2;
var y:Number = (this.parentApplication.mdiCanvas.height - window.height) / 2;
window.move(x, y);
}
}

3.主页面中要传入的值若是查询数据的一行,则可以转化为一个model,如下(VD3类似于java的model)

 private function onSelected(event:GridSelectionEvent):void
{
this.vD3 = DataGrid(event.target).selectedItem as VD3;
}
上一篇:【转】asp.net中设置弹出谈话框的几种方式详解


下一篇:MySQL介绍及安装(一)