13 Replies Latest reply on Apr 17, 2008 3:24 AM by Starlover_jacob


    GeorgeWS Level 1
      I have a ArrayCollection, myData

      the data fields are Vodka, Rum Gin with numbers in the fields.

      How do I pull out just the Vodka and put that in a <mx:Label>

      If you know how to do this maybe you can show me how to add up the Vodka + Rum and diplay that in a <mx:Label>

        • 1. Re: ArrayCollection
          ebrentnelson Level 1
          Can you post your code? It's nice to know why/how you are doing things so that we can better attend to your question.
          • 2. Re: ArrayCollection
            <mx:Label text="{{myData.getItemAt(myData.getItemIndex(Vodka)) + mData.getItem(myData.getItemIndex(Rum)).toString()}/>
            • 3. Re: ArrayCollection
              GeorgeWS Level 1
              It looks good but I cant get it to work.

              I get an error:
              Call to a possibly undefined method getItem through a reference with static type mx:collections:ArrayCollection

              also just a note: I did see 2 typos one there are 2 "{" in the biginning part. so I made it just 1.
              and mData to myData in the second part. so its like this

              <mx:Label text="{myData.getItemAt(myData.getItemIndex(Vodka)) + myData.getItem(myData.getItemIndex(Rum)).toString()}/>

              what could I be doing wrong ?

              • 4. Re: ArrayCollection
                AaffordableWeb Level 1
                getItemAt not getItem. Sorry for the typo.
                • 5. Re: ArrayCollection
                  AaffordableWeb Level 1
                  Full element retyped trying to fix my silly typing:

                  <mx:Label text="{(myData.getItemAt(myData.getItemIndex(Vodka) + myData.getItemAt(myData.getItemIndex(Rum)).toString()}"/>
                  • 6. Re: ArrayCollection
                    GeorgeWS Level 1
                    Thanks, it seems right but no go...

                    <mx:Label text="{myData.getItemAt(myData.getItemIndex(Vodka)) + myData.getItemAt(myData.getItemIndex(Rum)).toString()}"/>

                    Above is what I ended up with but there is nothing showing. Im sure there is data because in displaying some in a datagrid.

                    Anymore thoughts?

                    • 7. Re: ArrayCollection
                      ntsiii Level 3
                      Debug this by breaking it up into parts you can examine. There is way too much happening in this line for you to understand at once:
                      "{myData.getItemAt(myData.getItemIndex(Vodka)) + myData.getItemAt(myData.getItemIndex(Rum)).toString()}"

                      Put those values in variables, hard code for testing, etc.

                      • 8. Re: ArrayCollection
                        GeorgeWS Level 1
                        But thats no help. Its an easy statement:

                        "{myData.getItemAt(myData.getItemIndex(Vodka)) .toString()}"

                        Sitll no data from the arrayCollection

                        • 9. Re: ArrayCollection
                          ntsiii Level 3
                          I think perhaps you did not understand me?
                          Debug this by breaking it up into parts you can examine. Find where you CAN see the data, then approach this expression one step at a time.
                          • 10. Re: ArrayCollection
                            GeorgeWS Level 1
                            Why does this not work? (Vodka not receiving the result)

                            public var myPours:ArrayCollection;

                            public function handleQueryResult3(event:ResultEvent):void{
                            myPours=event.result as ArrayCollection;

                            public function addComp():void{
                            myChart.addItem({qBRAD53:"Competition", qCUSN05:Vodka, qCATG53:01});

                            <mx:Label text="{myData.getItemAt(myData.getItemIndex(Vodka)).toString()}"/>

                            The addComp is for another arrayCollection, Im showing this because I want the qCUSN05: to get the Vodka result from that line. So Im looking for the data in the label, cause im not sure how to trace it. I know the call works and there is data cause I can display the vodka in a datagrid. Im right there...

                            • 11. Re: ArrayCollection
                              GeorgeWS Level 1
                              oops im a dumby, should be like this I think:

                              <mx:Label text="{myPours.getItemAt(myPours.getItemIndex(Vodka)).toString()}"/>

                              I would think that a number like 21 would show up in the Label and hopefully in the addComp function.

                              • 12. ArrayCollection
                                Starlover_jacob Level 1
                                what if your arraycollection looks like this:
                                [1] data:3 label:vodka
                                [2] data:1 label:gin
                                [3] data: 2 label:rum

                                Greets, J.
                                • 13. Re: ArrayCollection
                                  Starlover_jacob Level 1
                                  I solved my problem

                                  i used this:
                                  I fill the arraycollection from the database. Data represents the id from the database and label represents the licker text.
                                  The licker text is ordered by name, so the data label does not match the id of the arraycollection.

                                  So lets say i know the id of soda(1).
                                  I now cannot say myarraycollection.getItemAt(1). If i do it will get me rum.
                                  so i did the following:

                                  ------------------------------------------------------------------------------------------ -----------------------------