9 Replies Latest reply on Mar 7, 2010 9:12 PM by Flex harUI

    How to use ICollectionView?

    adamgeework

      So im starting out to write my own custom class in Flex 3 builder.

       

      Im building off of uicomponent... but how do I extract the data from the ICollectionView?

       

      i've set a dataProvider function for my class and i want to place the array in textfields .

      All the examples ive seen just takes the array and uses it in an existing comonent.

        • 1. Re: How to use ICollectionView?
          Gregory Lafrance Level 6

          ICollectionView is an interface. Perhaps you are wondering how to make use of ArrayCollection.

           

          If your dataProvider ArrayCollection contains objects (or XMLListCollection with XML elements) you can bind the "text" property of the TextFields to the dataProvider fields.

           

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


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services

          1 person found this helpful
          • 2. Re: How to use ICollectionView?
            adamgeework Level 1

            I think it's just an array with no xml elements. It's an array from my database using amfphp.

            • 3. Re: How to use ICollectionView?
              RUSH-ME Level 3

              Hi

               

              Icollectionview is an interface implemented by collection classes like arraycollection.

              So for array its not required to use icollectionview.

               

              if you really want to use it then create a new arraycollection having source as your array.

               

              Rush-me

              1 person found this helpful
              • 4. Re: How to use ICollectionView?
                adamgeework Level 1

                Here is part of what I have minus the uicomponent stuff:

                    internal var _dataProvider : Array;

                    internal var text_mc:Text = new Text();

                 

                        public function get dataProvider() : Array{
                           
                            return _dataProvider;
                           
                        }

                 

                       
                        public function set dataProvider(value:Array):void{
                           
                            this._dataProvider = value;
                            invalidateProperties();
                            invalidateSize();
                            invalidateDisplayList();
                        }
                       
                  
                       
                        override protected function commitProperties():void{
                           
                            text_mc.text = _dataProvider[1];
                            text_mc.width = 500;
                            text_mc.height = 50;
                            addChild(text_mc);
                        }

                 

                 

                 

                I dont think i understand this material since it's not working.

                • 5. Re: How to use ICollectionView?
                  adamgeework Level 1

                  _dataProvider[1] should be giving me something?


                  • 6. Re: How to use ICollectionView?
                    Flex harUI Adobe Employee

                    Strictly speaking, mx.collections.ICollectionView is a specific way to

                    iterate through a set of data.  It is the most general and does not assume

                    you have indexed the data set.  It does not allow for array index access

                    (foo[1]).  Mx.collections.IList is yet another way to iterate through a set

                    of data.  It is simpler and assumes that you have relatively fast and

                    accurate indexing in the data set.

                     

                    ArrayCollection implements both interfaces and also allows for array access.

                    In Flex 4, the Spark components do not support ICollectionView and only

                    support mx.collections.IList.

                     

                    There are relatively few ICollectionView implementations other than

                    ArrayCollection.  If you are going to use ArrayCollection to wrap your

                    arrays, you can just go ahead and use array index access, but if you want to

                    be strict then you can't.  However, for new work, I would recommend use

                    mx.collections.IList as there seem to be very few non-indexed data sets in

                    the wild.

                    • 7. Re: How to use ICollectionView?
                      adamgeework Level 1

                      ok thanks.

                       

                      but my issue is that i dont know how to implement these methods, and can't find any examples.

                       

                      In flash or php I would take the array and throw it in a forloop. I'm not a coder so im lost in flex.

                      • 8. Re: How to use ICollectionView?
                        adamgeework Level 1

                        im just going to do it in the main mxml file and not in a separate as file because that is where the array isnt coming over properly

                        • 9. Re: How to use ICollectionView?
                          Flex harUI Adobe Employee

                          It depends on whether your ICollectionView is an ArrayCollection or not.  If

                          it is, you can iterate through it just like an array and use a for loop.  If

                          not and it implements mx.collections.IList, you can use getItemAt() to

                          iterate through it.  If you must use ICollectionView, you have to create a

                          cursor via createCursor() and use its moveNext() to iterate through it.