flex - How to send an ArrayCollection to a new/sub-window? -


yesterday phtrivier showed me how send array new/sub-window.

now have replaced static source of data xml file loads arraycollection. unfortunately found arraycollection behaves differently array when try send part of new/sub-window.

how can arraycollection?

or should take easy road sending array , instead way make xml load array instead of arraycollection? don't think require features 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 array, working-->     <s:button x="10" y="10" width="240" label="open sub-window 1" click="openwin1(staticdata[0]);"/>     <s:button x="10" y="30" width="240" label="open sub-window 2" click="openwin1(staticdata[1]);"/>     <!--opening windows, adding arraycollection, not working-->     <s:button x="10" y="60" width="240" label="open sub-window 1" click="openwin2(xmldata.getitemat(5));"/>     <s:button x="10" y="80" width="240" label="open sub-window 2" click="openwin2(xmldata[5].source);"/>     <s:button x="10" y="100" width="240" label="open sub-window 3" click="openwin2(xmldata.getitemat(5).source);"/> </s:windowedapplication> 

mywindow1.mxml (should fine, 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> 

found own solution: xml loaded comes in arraycollection needed run through repeater anyway. when ran through repeater arrays inside become object. have experience objects arraycollections trial & error found following working code. yay!

// mymain.mxml // inside repeater click="openwin(event.currenttarget.getrepeateritem())"  // mymain.mxml // opening window , sending 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 data public function set transferdata(transferdata:object):void {     this.windowdata = transferdata; }  // mywindow.mxml // use data <mx:label text="{windowdata.author}"/> 

while isn't sending arraycollection, solved problem , may make sending actual arraycollection easy.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -