Reputation: 1597
I am very new to flex and flash builder. What I am trying to do is connect to a http data service and retrieve data from it.
All the tutorials I have found go through the process of setting up the data service and taking the response and putting it in a grid.
Wheat I am not understanding (and it is probably really simple.) is how to take the response and instead of putting it into a data grid, just store the results in variables for later use.
If someone can help me get going with this, it would be very much appreciated.
Upvotes: 0
Views: 527
Reputation: 39408
first create a variable for you to store the results:
public var results : ArrayCollection;
Then in you result handler, just store the values:
protected function resultHandler(event:ResultEvent):void{
results = new ArrayCollection(event.result as Array);
}
Upvotes: 2
Reputation: 25489
Slight difference to Flextras's answer:
public var results : ArrayCollection;
Then in you result handler, just store the values:
protected function resultHandler(event:ResultEvent):void{
if(event.result is Array)
results = new ArrayCollection(event.result as Array);
else if(event.result is IList)
results = new ArrayCollection(event.result.source);
else
results = new ArrayCollection([event.result]);
}
Now usually this checking of the type of the event.result
is not required because most webservices will be consistent in the return type. So, all you need to do is debug the application and insert a breakpoint at the entry to the resultHandler
function. Then watch the event.result
and note its type, and depending on that, retain the corresponding line of code.
P.S.: IList
is an interface implemented by the ArrayCollection
, ArrayList
, and many other classes, so if the result is one of these classes, then you need to keep that line.
Upvotes: 1