6 Replies Latest reply on Jun 29, 2010 7:29 PM by Don Kerr

    s:List selectedItems

    Don Kerr Level 3

      In Flex 3, it was simple to pass selectedItems from a list to a RemoteObject.   I simply added list.selectedItems to an object and passed the object to the ro, and used the array on server side. Easy.


      Now, with Flex 4, it has a complicated Vector of Objects that is not so straight forward and blows up the RO calls with AMF 16 exception.


      How do get the selectedItems into an Array or Array of Objects vs. a Vector, so it will be accepted by AMF?

      this is what does not work any longer with a spark list, but used to work with Flex 3 lists...

      var o:Object = new Object();

      o.choices1 = list1.selectedItems;

      o.choices2 = list2.selectedItems;

      o.choices3 = list3.selectedItems;



      How do I change it so it works with a spark list?



      Don Kerr

        • 1. Re: s:List selectedItems
          Flex harUI Adobe Employee

          I think folks are converting the Vector to an array in a for-each loop.

          • 2. Re: s:List selectedItems
            Don Kerr Level 3

            so much for progress...


            spark so far does seem to have taken away power from the developer, while given amazing power to the designer.  Tough trade.


            I'm not familar with looping over Vectors.


            Have a simple example?



            • 3. Re: s:List selectedItems
              Flex harUI Adobe Employee

              I think I would do:


              Var n:int = v.length;

              Var arr:Array = new Array(n);

              For (var i:int = 0; i<n; i++)

                  arr[i] = v[i];

              • 4. Re: s:List selectedItems
                Don Kerr Level 3

                Thanks.  I'll give it a try.


                http://www.mikechambers.com/blog/2008/08/19/using-vectors-in-actionscript-3-and-flash-play er-10/

                Rhetorically speaking, I'm curious, if vectors create better performance over arrays, then why are they not supported by AMF?


                Not happy about the extra work Flex 4 requires with lists... obviously.


                But, maybe it is just my ignorance.  Maybe I have to learn and adapt.


                I appreciate the help.  And for letting me vent a little.




                • 5. Re: s:List selectedItems
                  Flex harUI Adobe Employee

                  It's a bug.  I'm pretty sure I saw it on a priority list recently.

                  • 6. Re: s:List selectedItems
                    Don Kerr Level 3

                    Flex 3  o.c = cList.selectedItems


                    Flex 4


                                    var vC:Vector.<Object> = cList.selectedItems;
                                    var nC:int = vC.length;
                                    var cA:Array = new Array(nC);

                                    for (var i:int = 0; i<nC; i++){
                                        cA[i] = vC[i];
                                    var cAC:ArrayCollection = new ArrayCollection(cA);
                                    var o:Object = new Object();
                                    o.blongID = blongID;
                                    o.c = cAC ;


                    This Flex 4 code works when talking to a ColdFusion CFC


                    <cfif ISARRAY(mydata.c)>
                            <cfif #ArrayLen(mydata.c)# GT 0>
                                <cfloop from="1" to="#ArrayLen(mydata.c)#" index="i">
                                    <cfquery name="insert" datasource="#dsn#">
                                    INSERT INTO blong_Links (fromID,toID)
                                    VALUES (#mydata.blongID#,#mydata.c[i].blongID#)


                    Thanks for the help.