This is probably the Object vs Array problem.  The player is unable to
differentiate between an array with a single element and an object.
Test by adding another "data" node.

 

I advise changing the default resultFormat to "e4x" and doing the
conversion to ArrayCollection manually, instead of letting Flex do it
for you.  Or use XMLListCollection directly.

 

Accepted best practice seems to be using resultFormat="e4x" and building
an ArrayCollection of strongly typed VOs.

 

If you are committed to staying with the default resultFormat, you will
need to inspect the event.result object to determine what it contains,
and code for the two cases.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of netdeep
Sent: Tuesday, September 16, 2008 11:29 AM
To: [email protected]
Subject: [flexcoders] HTTPService conversion to ArrayCollection problem

 

This is really bizarre but I have some code that was working previously
and now is no longer working. I 
am using a servlet to output information in the following format:

<system>
<data>
<name>Channel 1</name>
<id>Rep1</id>
</data>
</system>

But I am now getting a runtime error: Error #1034: Type Coercion failed:
cannot convert 
mx.utils::[EMAIL PROTECTED] to mx.collections.ArrayCollection

Code:

public function initializeBrowser(evt:ResultEvent):void {
var arr:ArrayCollection = evt.result.system.data;
}

<mx:HTTPService id="reportsList" result="initializeBrowser(event)"
useProxy="false"
method="GET" url="{dbURL}"/>

 

Reply via email to