Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
Adobe Flex SDK Previous
-
None
-
None
-
Affected OS(s): All OS Platforms
Affected OS(s): All OS Platforms
Language Found: English
Description
Steps to reproduce:
From http://forums.adobe.com/thread/511477?tstart=0
The following mxml code imports an xml file and reports the length of the ArrayCollection into which the xml is loaded. If the xml file contains only a single <distractor> element I get this error message:
TypeError: Error #1034: Type Coercion failed: cannot convert mx.utils::ObjectProxy@1d865821 to mx.collections.ArrayCollection.
If the main xml node contains more than one <distractor> element, it works. Is there a problem with the way the xml is written or is there something else I'm doing wrong?
Here's the xml. The file name is temp.xml:
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<distractorsList>
<distractor>
<testData>AAA</testData>
</distractor>
<distractor>
<testData>BBB</testData>
</distractor>
</distractorsList>
Here's the mxml code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
private function init():void{
var service:HTTPService = new HTTPService();
service.url = "temp.xml"
service.method = "GET";
service.addEventListener("result", recordsReturned);
service.send()
}
private function recordsReturned(event:ResultEvent):void{
var arrayCollection:ArrayCollection=event.result.distractorsList.distractor
trace("xx="+arrayCollection.length)
}
]]
>
</mx:Script>
</mx:Application>
Actual Results:
Expected Results:
Workaround (if any):