This content has been marked as final. Show 6 replies
products = rmOther.getProducts.lastResult;
will NEVER work, and might be causing problems (do you understand why?). Remove it to see if it helps.
But it DOES work, the thing is that let's say 30% of the time the array is null and therefore an error arises when trying to access that ArrayCollection. That's what I dont have a clue why is happening.
So bottom line, 70% of the time the ArrayCollection does have several String objects loaded from the database, and the application goes well, 30% of the time the ArrayCollection is a null and an error arises.
That particular line will never work. Take it out and see if things improve.
Tracy - please explain why "products = rmOther.getProducts.lastResult;
" will not work. is it due to this call being a RO and not a HTTPService?
Well it does work, sometimes, I'm interested in knowing if that is just not a good practice and what other way do I have to asign to my ArrayCollection variable the result of the RO request. This is getting interesting. Thanks
Because all data access in Flex is asynchronous. You can never access result data in the same function in which you make the call.
In fact, when these lines run:
line 2:products = rmOther.getProducts.lastResult;
Line 2 runs BEFORE line 1. It can never have the *correct* result, but could be trashing the contents of the products variable.
What IS working is this handler is being called:
private function resultHandler(event:ResultEvent):void
products = event.result as ArrayCollection; //THIS WILL WORK
You can only acces results in a handler or by binding, which I do not advise.