This isn't a question; I was having some trouble with this and just
figured it out, and I thought you all might like to hear about it.
This list has been a big help to me in the past and I'd like to return
the favor.

THE PROBLEM
So you've created your XMLListCollection, and you created your Sort
object and refreshed your collection. You want to use the IViewCursor
findAny() method to set the cursor on one of the values, specifically
the XML node whose Value attribute is "foo". You might say:

var valueSort : Sort = new Sort();
valueSort.fields = [ new SortField("Value") ];
var xmlcoll : XMLListCollection = new XMLListCollection(
someXML.Values ); //list of <Values /> nodes
xmlcoll.sort = valueSort;
xmlcoll.refresh();
var cursor : IViewCursor = xmlcoll.createCursor();
var xobj : XML = { Value: "foo" }
trace( cursor.findAny( xobj ) ); // returns false!

The findAny won't work! And it won't help if you try to get cute with
some e4x on your sort, like  new SortField("@Value"). Didn't for me
anyway.

THE SOLUTION
When creating the search object to pass into the findAny() method, you
need to create an XML object and not a plain object.Replace the line
beginning with "var xobj" with the following:

var xobj : XML = <Values />; // xml literal with nodename that matches
 the ones in your list
[EMAIL PROTECTED] = "foo"; // give it an attribute matching the one you are
looking for
trace( cursor.findAny( xobj ) ); //returns true!

And there we go.  Fight on you flexcoders!

Reply via email to