Continuing in the tradition of replying to my own posts when I find
the solution...
I found the issue is caused by the fill method being processed
asynchronously to the actionscript execution (duh!) I didn't know
that obviously ;)
I just moved my code that processes the returned object into an event
handler that gets called when a result is returned by the fill...
So one question, is there a way to avoid "filling" the first array
collection and just dealing with the object that is returned in the
ResultEvent?
it looks like this (it's ugly):
private function getAdminOption(username:String):void
{
var theUser:ArrayCollection = new ArrayCollection;
ID_USERS.addEventListener("result", processAdminOption);
ID_USERS.fill(theUser,"IdUser.single",[username]);
}
private function processAdminOption(event: ResultEvent):void
{
if (event.result.length != 0)
{
if (event.result[0].administratorGroupKey == 1)
{
currentState='AdminOption';
}
else
{
currentState='';
}
}
else
{
currentState='';
}
}
cheers,
JK
--- In [email protected], "ripe101" <[EMAIL PROTECTED]> wrote:
>
> I have a fill method being called in an event handler, and I can
see
> the correct data coming back in FDS (from Hibernate), but my
> ArrayCollection is empty the first time the method is called.
>
> If I trigger the exact same event with the same parameter a second
> time it behaves as expected. I think I am missing something
subtle...
>
> the event handler is as follows:
>
> private function getAdminOption(username:String):void
> {
> var theUser:ArrayCollection = new ArrayCollection;
> ID_USERS.fill(theUser,"IdUser.single",[username]);
> if (theUser.length != 0)
> {
> if (theUser.getItemAt(0).administratorGroupKey == 1)
> {
> currentState='AdminOption';
> }
> else
> {
> currentState='';
> }
> }
> }
>
> Anyone else seen this happen?
>
> Thanks
> JK
>