thanks paul

On 2/14/07, Paul DeCoursey <[EMAIL PROTECTED]> wrote:

I had a similar situation with ArrayCollection.  what I do it iterate
through the collection and return the item if I find one that matches.

I created an ArrayCollectionIterator Class that helps with this.

        public class ArrayCollectionIterator implements IIterator {

                private var collection:ArrayCollection;
                private var nextIndex:Number = 0;

                public function
ArrayCollectionIterator(collection:ArrayCollection) {
                        this.collection = collection;
                }

                public function hasNext():Boolean {
                        return (this.nextIndex<this.collection.length);
                }

                public function next():Object {
                        if(!this.hasNext()) {
                                throw new Error("No more elements
available");
                        }
                        var obj:Object = this.collection[this.nextIndex];
                        nextIndex++;
                        return obj;
                }

                public function reset():void {
                        nextIndex = 0;
                }

        }


So the idea is I have a function that querys the list and returns the
item if found and null if not.  Then with the calling function I
either add or update based on the response.  Let me know if you need
more specific eexamples.  You should be able to adapt the above Class
to use the XMLListCollection.

pd

--- In flexcoders@yahoogroups.com, "dorkie dork from dorktown"
<[EMAIL PROTECTED]> wrote:
>
> I'm trying to find if a row with the same name exists in an XML List
> Collection. The problem is, the e4x I try is not supported by
> XMLListCollection. I keep getting a Error #1123: Filter operator not
> supported on type mx.collections.XMLListCollection.
>
> Here is my code:
>
>      public function addNewProject(event:FlexEvent):void {
>          var projectName:String = project.text;
>          var exists:Boolean = projectsList.(@name == projectName);
>
>          if (!exists) {
>             var newNode:XML = <project name=""/>;
>             [EMAIL PROTECTED] = project.text;
>             newNode.created = new Date();
>             projectsList.addItemAt(newNode, 0);
>          }
>      }
>
>
> TypeError: Error #1123: Filter operator not supported on type
> mx.collections.XMLListCollection.
>




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links




Reply via email to