How do I use data from the main window in a sub-window?

Posted by eagle on Stack Overflow See other posts from Stack Overflow or by eagle
Published on 2011-06-30T04:59:05Z Indexed on 2011/06/30 8:22 UTC
Read the original article Hit count: 258

Filed under:
|
|

I've just started working on a photo viewer type desktop AIR app with Flex. From the main window I can launch sub-windows, but in these sub-windows I can't seem to access the data I collected in the main window.

How can I access this data?
Or, how can I send this data to the sub-window on creation? It doesn't need to be dynamically linked.

myMain.mxml

    <?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       width="260" height="200"
                       title="myMain">
    <fx:Declarations>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            public function openWin():void {
                new myWindow().open();
            }

            public var myData:Array = new Array('The Eiffel Tower','Paris','John Doe');
        ]]>
    </fx:Script>
    <s:Button x="10" y="10" width="240" label="open a sub-window" click="openWin();"/>
</s:WindowedApplication>

myWindow.mxml

    <?xml version="1.0" encoding="utf-8"?>
<mx:Window name="myWindow"
           title="myWindow"
           xmlns:mx="http://www.adobe.com/2006/mxml"
           layout="absolute"
           width="640" height="360">
    <mx:Script>
        <![CDATA[

        ]]>
    </mx:Script>
    <mx:Label id="comment" x="10" y="10" text=""/>
    <mx:Label id="location" x="10" y="30" text=""/>
    <mx:Label id="author" x="10" y="50" text=""/>
</mx:Window>

I realize this might be a very easy question but I have searched the web, read and watched tutorials on random AIR subjects for a few days and couldn't find it. The risk of looking like a fool is worth it now, I want to get on with my first app!

© Stack Overflow or respective owner

Related posts about flex

Related posts about air