• 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.然后在主页面中调用它:用到如下函数

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

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

    1 private function onSelected(event:GridSelectionEvent):void
    2             {
    3                 this.vD3 = DataGrid(event.target).selectedItem as VD3;
    4             }
    我很小我很弱,我在慢慢成长!
  • 相关阅读:
    案例分析
    202103226-1 编程作业
    阅读任务
    准备工作
    结对作业
    案列分析
    202103226-1 编程作业
    《构建之法》有感
    准备工作
    案例分析作业
  • 原文地址:https://www.cnblogs.com/lvzhanhui/p/xiaoqiaolv_flex_titleWindow.html
Copyright © 2020-2023  润新知