Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6150615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:38:21+00:00 2026-05-23T19:38:21+00:00

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

  • 0

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

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:38:22+00:00Added an answer on May 23, 2026 at 7:38 pm

    Found my own solution: The XML loaded comes in as ArrayCollection but I needed to run it through a repeater anyway. When ran through a repeater the arrays inside become an Object. I have just as much experience with Objects as ArrayCollections BUT by trial & error I found the following working code. Yay!

    // MyMain.mxml // inside the repeater
    click="openWin(event.currentTarget.getRepeaterItem())"
    
    // MyMain.mxml // opening the window and sending the data
    private function openWin(transferData:Object):void
    {
        var w:MyWindow = new MyWindow();
        w.transferData = transferData;
        w.open();
    }
    
    // MyWindow.mxml // variables
    [Bindable] private var windowData:Object;
    
    // MyWindow.mxml // receive the data
    public function set transferData(transferData:Object):void
    {
        this.windowData = transferData;
    }
    
    // MyWindow.mxml // use the data
    <mx:Label text="{windowData.author}"/>
    

    While this isn’t sending an ArrayCollection, it solved my problem and may make sending an actual ArrayCollection very easy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yesterday, I asked this question and never really got an answer I was really
Yesterday, I discovered the Subversion (SVN) blame feature, and I was wondering, is this
Yesterday, I found myself writing code like this: SomeStruct getSomeStruct() { SomeStruct input; cin
Yesterday, I have a discussion with my colleagues about HTTP. It is asked why
Yesterday I found this function: function clone(obj) { return typeof obj === 'undefined' ?
Yesterday I had to parse a very simple binary data file - the rule
Yesterday I have been testing one single query for over hours and hours, but
Yesterday Oracle decided to take down java.sun.com for a while. This screwed things up
Yesterday i tried to use std::unordered_map and this code confused me how much memory
Yesterday,in an Interview I have been asked to test the 5th bit in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.