I agree that you are probably better doing the backend search, but if you need
to do it in your app here's the proper way to sort. You just missed declaring a
sort as a new object (then since you didn't have an object you were trying to
apply sortfields to an AC) and then you apply that new sort to your AC.
private function private function userHandler(event:ResultEvent):void{
acUsers = evt.result.rows.row;
var sort:Sort = new Sort();
sort.fields = [new SortField("usraccount",true)];
acUsers.sort = sort;
acUsers.refresh();
}
--- In [email protected], "valdhor" <valdhorli...@...> wrote:
>
> You are probably better off checking if the new user has entered an already
> used account name on the back end and sending through a Yes/No answer to Flex.
>
> Anyway, You should be able to figure out how to do a sort by perusing this
> example:
>
> http://blog.flexexamples.com/2007/08/05/sorting-an-arraycollection-using-the-sortfield-and-sort-classes/
>
> --- In [email protected], "criptopus" <sd_brown@> wrote:
> >
> > Don't understand why im getting these errors, can anybody help?
> >
> > I have just created an arrayCollection from a HTTPService that reads a
> > table from my database. I am trying to check to see if the new user has
> > entered an already used account name.
> >
> > After reading a number of articles I discovered searching the
> > arrayCollection was possible but only after sorting the collection, this is
> > what I am having trouble with.
> >
> > Here is my code:
> >
> > private function userHandler(event:ResultEvent):void
> > {
> > acUsers = event.result.response.data.row;
> > acUsers.fields = [new SortField("usraccount", true)];
> > acUsers.sort=acUsers;
> > acUsers.refresh();
> > }
> >
> > I am getting the following error at (acUsers.sort=acUsers;):
> >
> > implicit coercion of a value of type
> > mx.collections:ArrayCollection
> > to an unrelated type
> > mx.collections:Sort.
> >
> > and also an error at (acUsers.fields = [new SortField("usraccount", true)];)
> >
> > Access of possibly undefined property
> > fields through a refrence with static type mx.collections:ArrayCollection.
> >
>