4 Replies Latest reply on May 19, 2010 9:23 AM by mangemuck

    TileList - loop through items

    mangemuck

      Hey!

       

      At application start I'm trying to loop through the items in a TileList.

       

      How can I do this?

      /Magnus

        • 1. Re: TileList - loop through items
          BhaskerChari Level 4

          Hi,

           

          You should loop through the tilelist dataprovider as shown below:

           

          for(var i:int=0;i<tileListDP.length;i++)
             {
              var objItem:Object = tileListDP.getItemAt(i);
             }

           

          tileListDP is your tilelist dataprovider.

           

          If this post answers your question or helps, please kindly mark it as such.

           

          Thanks,

          Bhasker Chari

          1 person found this helpful
          • 2. Re: TileList - loop through items
            mangemuck Level 1

            Thanks for your answer. It helped.

             

            (I changed tileList.length to tileList.data.length since only length didn't work.)

             

            However, Flash Builder complains at getItemAt:

            Call to a possibly undefined method getItemAt through a reference with static type mx.controls:TileList

             

            /Magnus

            • 3. Re: TileList - loop through items
              nIvelyx

              You have to call the .getItemAt on your data provider (e.g. if you have an ArrayCollection for your data provider, you could call "myArrayCollection.getItemAt(i)"... You can't reference .getItemAt on the actual list itself or else you'll get that 1061 error.

               

              Hope this helps.

              1 person found this helpful
              • 4. Re: TileList - loop through items
                mangemuck Level 1

                Thanks.

                 

                The problem is that I have an XMLList. It seems hard to get the index of a node in that XMLList.

                 

                I tried this:

                 

                var i:int;
                var src:String = "";
                var obj:Object = getPictureList; // The XMLList
                var objItem:Object;
                
                for(i = 0; i < obj.length; i++) {
                     objItem = obj.getItemAt(i);
                }
                

                 

                The length property returns nothing (not null, not zero - nothing).

                 

                Sorry if I'm being a pain

                 

                /Magnus