flex实现父窗口向子窗口传递参数

flex实现父窗口向子窗口传递参数

代码展示

父窗口

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"                                                minWidth="955" minHeight="600">

    <fx:Script>
        
    fx:Script>

    <fx:Declarations>
        
        <s:Label  text="纳税人"/>
    fx:Declarations>

    <s:VGroup x="41" y="27" width="337" height="227" >
        <s:Label id="label1" width="103" text="123"/>
        <s:HGroup horizontalAlign="center"  gap="100" width="100%" height="90" >
            <s:Button label="视频一" click="button2_clickHandler(event)" />            
        s:HGroup>
    s:VGroup> 
s:Application>
子窗口
"1.0" encoding="utf-8"?>
"http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"
                    creationComplete="bordercontainer1_creationCompleteHandler(event)" >
    
        import mx.controls.Alert;
            import mx.events.FlexEvent;

            public var mytext:String;

            protected function image1_clickHandler(event:MouseEvent):void
            {
                this.visible=false;
            }   
            protected function bordercontainer1_creationCompleteHandler(event:FlexEvent):void
            {

                var lujing:String="assets/"+ mytext +".mp4";                
                vd1.source=lujing;
            }

        ]]>
    
    
        
    
    "vd1" x="-1" y="-1" width="314" height="230" chromeColor="#9A9898"/>
    "286" y="-2" width="29" height="32" source="assets/关闭(1).png" buttonMode="true" click="image1_clickHandler(event)"/>


flex实现父窗口向子窗口传递参数_第1张图片
关键点

  • 子窗口中添加变量public var mytext:String;
  • 主窗体内将值传给mytext例如:tw.mytext=label1.text;

你可能感兴趣的:(flex)