5 Replies Latest reply on Jan 13, 2012 11:31 AM by DonMitchinson

    arraycollection of arraycollection setting assigned values of the original?

    BosDog

      hi... i'm pretty puzzled on this one. here is the situation... on my main flex app I define an arraycollection:

       

      public var fiscalYrsArray:ArrayCollection;

       

      The collection gets populated from results from a query to a CFC

       

      protected function fiscalYrs_resultHandler(event:ResultEvent):void{

                      for (var x:int = 0; x < event.result.length; x++){

                          if (event.result[x].DATA == passData.filterFiscalYrs){

                              event.result[x].assigned = true;

                          }

                      }

                      fiscalYrsArray = event.result as ArrayCollection;

                  }

       

      I have a popup window from the main app with dropdowns (i'm using a multi-check box combobox). i'm using this window as a filter window where users can pick what they want filtered.

      on that component i'm using a temporary arraycollection (b/c i don't want to edit the assignments of the arraycollection the temp one is based off of) that will be a copy of the fiscalYrsArray collection from the parentApplication:

       

      <s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" close="PopUpManager.removePopUp(this)"

               xmlns:s="library://ns.adobe.com/flex/spark" title="Filter Data" creationComplete="initComp();"

               xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"

               xmlns:multiPickBox="components.multiPickBox.*">

          <fx:Declarations>

              <!-- Place non-visual elements (e.g., services, value objects) here -->

          </fx:Declarations>

         

          <fx:Script>

              <![CDATA[

                  import mx.collections.ArrayCollection;

                  import mx.controls.Alert;

                  import mx.managers.PopUpManager;

                 

                  private var tempfilterFiscalYrs:String

                  [Bindable]private var fiscalYrDP:ArrayCollection = new ArrayCollection;

                 

                  private function initComp():void{

                      fiscalYrDP = parentApplication.fiscalYrsArray;

                      tempfilterFiscalYrs = parentApplication.passData.filterFiscalYrs;

                  }

       

                protected function msc_addItemHandler(event:Event,filterVal:String,comboId:String):void

                  {

                      //Alert.show('got here');

                      this[filterVal]='';

                      for each (var item:Object in this[comboId].selectedItems) {

                          this[filterVal]+=item['DATA']+',';   

                      }

                      //filterChange = true;

                      //idText.text = str;

                  }   

       

      I'm binding the filterYrDP arraycollection to a custom multi pick combobox:

       

      <multiPickBox:CheckCombo id="fiscalYearF" width="162" dataProvider="{fiscalYrDP}"

                                   addItem="msc_addItemHandler(event,'tempfilterFiscalYrs','fiscalYearF')"

                                   allIndex="0" x="77" y="17" labelField="DATA"/>

       

      I'm finding though that when an item is checked the assigned = true value is actually being applied to the original fiscalYrsArray from my parentApplication. i only want the assigned = true to be applied to the fiscalYrDP arraycollection (the one that is based on the parentApplication fiscalYrsArray). how could it be writing back and changing the properties of the main one if its just a temporary copy of it?