How to send an ArrayCollection to a new/sub-window?
Yesterday phtrivier showed me [how to send an array to a new/sub-window][1].

Now I have replaced this static source of data with an XML file that loads into an ArrayCollection. Unfortunately I found an ArrayCollection behaves differently than an Array when you try to send a part of it to a new/sub-window.

How can I do this with the ArrayCollection?

Or should I take the easy road with sending an Array and instead look for a way to make the XML load into an Array instead of an ArrayCollection? I don't think I will *require* the extra features an AC offers.

MyMain.mxml

    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication ...stuff... creationComplete="settingService.send()">
        <fx:Declarations>
            <s:HTTPService id="settingService" url="data.xml" result="settingService_resultHandler(event)"/>
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                // import dependencies
                import mx.collections.ArrayCollection;
                import mx.rpc.events.ResultEvent;
    
                // variables
                [Bindable] private var xmlData:ArrayCollection;
    
                // collect static data
                private var staticData1:Array = new Array('The Eiffel Tower','Paris','John Doe');
                private var staticData2:Array = new Array('The Strip','Las Vegas','Jane Doe');
                private var staticData:Array = new Array(staticData1, staticData2);
    
                // collect xml data
                protected function settingService_resultHandler(event:ResultEvent):void
                {
                    xmlData = event.result.settings.photo;
                }
    
                // open window & send data in Array, WORKING
                public function openWin1(inData:Array):void
                {
                    var w:MyWindow1 = new MyWindow1();
                    w.inData = inData;
                    w.open();
                }
    
                // open window & send data in ArrayCollection, NOT WORKING
                public function openWin2(inData:ArrayCollection):void
                {
                    var w:MyWindow2 = new MyWindow2();
                    w.inData = inData;
                    w.open();
                }
            ]]>
        </fx:Script>
        <!--opening windows, adding an array, WORKING-->
        <s:Button x="10" y="10" width="240" label="open a sub-window 1" click="openWin1(staticData[0]);"/>
        <s:Button x="10" y="30" width="240" label="open a sub-window 2" click="openWin1(staticData[1]);"/>
        <!--opening windows, adding an arraycollection, NOT WORKING-->
        <s:Button x="10" y="60" width="240" label="open a sub-window 1" click="openWin2(xmlData.getItemAt(5));"/>
        <s:Button x="10" y="80" width="240" label="open a sub-window 2" click="openWin2(xmlData[5].source);"/>
        <s:Button x="10" y="100" width="240" label="open a sub-window 3" click="openWin2(xmlData.getItemAt(5).source);"/>
    </s:WindowedApplication>

MyWindow1.mxml (should be fine, its working after all)

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Window ...stuff...>
        <mx:Script>
            <![CDATA[
                // variables
                [Bindable] private var windowData:Array;
    
                // receive data
                public function set inData(outData:Array):void {
                    this.windowData = outData;
                }
            ]]>
        </mx:Script>
        <mx:TextInput id="comment" x="10" y="10" text="{windowData[0]}"/>
        <mx:TextInput id="location" x="10" y="30" text="{windowData[1]}"/>
        <mx:TextInput id="author" x="10" y="50" text="{windowData[2]}"/>
    </mx:Window>

MyWindow2.mxml

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Window ...stuff...>
        <mx:Script>
            <![CDATA[
                // import dependencies
                import mx.collections.ArrayCollection;
    
                // variables
                [Bindable] private var windowData:ArrayCollection;
    
                // receive data
                public function set inData(outData:ArrayCollection):void {
                    this.windowData = outData;
                }
            ]]>
        </mx:Script>
        <mx:TextInput id="comment" x="10" y="10" text="{windowData.comment}"/>
        <mx:TextInput id="location" x="10" y="30" text="{windowData.location}"/>
        <mx:TextInput id="author" x="10" y="50" text="{windowData.author}"/>
    </mx:Window>


  [1]: http://stackoverflow.com/questions/6530108/how-do-i-use-data-from-the-main-window-in-a-sub-window
How to send an ArrayCollection to a new/sub-window?
===

Yesterday phtrivier showed me [how to send an array to a new/sub-window][1].

Now I have replaced this static source of data with an XML file that loads into an ArrayCollection. Unfortunately I found an ArrayCollection behaves differently than an Array when you try to send a part of it to a new/sub-window.

How can I do this with the ArrayCollection?

Or should I take the easy road with sending an Array and instead look for a way to make the XML load into an Array instead of an ArrayCollection? I don't think I will *require* the extra features an AC offers.

MyMain.mxml

    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication ...stuff... creationComplete="settingService.send()">
        <fx:Declarations>
            <s:HTTPService id="settingService" url="data.xml" result="settingService_resultHandler(event)"/>
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                // import dependencies
                import mx.collections.ArrayCollection;
                import mx.rpc.events.ResultEvent;
    
                // variables
                [Bindable] private var xmlData:ArrayCollection;
    
                // collect static data
                private var staticData1:Array = new Array('The Eiffel Tower','Paris','John Doe');
                private var staticData2:Array = new Array('The Strip','Las Vegas','Jane Doe');
                private var staticData:Array = new Array(staticData1, staticData2);
    
                // collect xml data
                protected function settingService_resultHandler(event:ResultEvent):void
                {
                    xmlData = event.result.settings.photo;
                }
    
                // open window & send data in Array, WORKING
                public function openWin1(inData:Array):void
                {
                    var w:MyWindow1 = new MyWindow1();
                    w.inData = inData;
                    w.open();
                }
    
                // open window & send data in ArrayCollection, NOT WORKING
                public function openWin2(inData:ArrayCollection):void
                {
                    var w:MyWindow2 = new MyWindow2();
                    w.inData = inData;
                    w.open();
                }
            ]]>
        </fx:Script>
        <!--opening windows, adding an array, WORKING-->
        <s:Button x="10" y="10" width="240" label="open a sub-window 1" click="openWin1(staticData[0]);"/>
        <s:Button x="10" y="30" width="240" label="open a sub-window 2" click="openWin1(staticData[1]);"/>
        <!--opening windows, adding an arraycollection, NOT WORKING-->
        <s:Button x="10" y="60" width="240" label="open a sub-window 1" click="openWin2(xmlData.getItemAt(5));"/>
        <s:Button x="10" y="80" width="240" label="open a sub-window 2" click="openWin2(xmlData[5].source);"/>
        <s:Button x="10" y="100" width="240" label="open a sub-window 3" click="openWin2(xmlData.getItemAt(5).source);"/>
    </s:WindowedApplication>

MyWindow1.mxml (should be fine, its working after all)

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Window ...stuff...>
        <mx:Script>
            <![CDATA[
                // variables
                [Bindable] private var windowData:Array;
    
                // receive data
                public function set inData(outData:Array):void {
                    this.windowData = outData;
                }
            ]]>
        </mx:Script>
        <mx:TextInput id="comment" x="10" y="10" text="{windowData[0]}"/>
        <mx:TextInput id="location" x="10" y="30" text="{windowData[1]}"/>
        <mx:TextInput id="author" x="10" y="50" text="{windowData[2]}"/>
    </mx:Window>

MyWindow2.mxml

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Window ...stuff...>
        <mx:Script>
            <![CDATA[
                // import dependencies
                import mx.collections.ArrayCollection;
    
                // variables
                [Bindable] private var windowData:ArrayCollection;
    
                // receive data
                public function set inData(outData:ArrayCollection):void {
                    this.windowData = outData;
                }
            ]]>
        </mx:Script>
        <mx:TextInput id="comment" x="10" y="10" text="{windowData.comment}"/>
        <mx:TextInput id="location" x="10" y="30" text="{windowData.location}"/>
        <mx:TextInput id="author" x="10" y="50" text="{windowData.author}"/>
    </mx:Window>


  [1]: http://stackoverflow.com/questions/6530108/how-do-i-use-data-from-the-main-window-in-a-sub-window