I'm getting the dreaded Type Coercion error on this line:
resourcesAC = event.result.resources.resource;
resourcesAC is declared as follows:
[Bindable]
private var resourcesAC : ArrayCollection = new ArrayCollection();
My result handler for my HTTPService is:
private function handleRscListResult(event:ResultEvent):void{
resourcesAC = event.result.resources.resource;
var rscObj:Object = new Object();
rscObj.name = "--New Resource--";
rscObj.resourceID = 0;
resourcesAC.addItemAt(rscObj, 0);
rscBox.rscListCB.selectedIndex=0;
}
Turns out that event.result.resources.resource is empty, which is
why I'm getting the error. However, I can't figure out why this is
empty. Here's my event.result:
<resources type="array">
<resource>
<capacity type="integer">1</capacity>
<created_at type="datetime" nil="true"/>
<desc>The grocery store server</desc>
<id type="integer">2</id>
<name>Rclerk</name>
<simulation_id type="integer">4</simulation_id>
<time_units>sec</time_units>
<updated_at type="datetime" nil="true"/>
</resource>
</resources>
When I check the length of event.result.resources.resource using
trace(event.result.resources.resource.length()), I get 0.
Why is this? Seems to me it should be 1 - there's one <resource>
object in there!
The only other guess I have is that somehow "resources"
and "resource" are magic words. I was checking my routes.rb file
today and noticed the following route:
map.resources :resources
which struck me as looking peculiar today.
Has anyone run across this before?
Thanks,
LG