When Flex converts xml into flex data types, it makes its best guess
as to hat is appropriate.  When it sees repeating elements it decides
arrayCollection.  When it sees a single element or multiple different
elements it decides objectProxy.

You need to check the type of the event.result.action.item and set
jobDetails to it if it is an array collection, or make jobDetails a
new arrayCollect and addItem(event.result.action.item) to it if it is
an objectProxy.

--- In [email protected], "oneproofdk" <[EMAIL PROTECTED]> wrote:
>
> Hi All.
> I am using a HTTPservice to retrieve data, it works fine when there's
> multiple items in the xml.
> But if there's only one (1) item in the data, it fails with this error:
> 
> Type Coercion failed: cannot convert mx.utils::[EMAIL PROTECTED] to
> mx.collections.ArrayCollection.
> 
> Can anyone please shed some light on this issue ?
> 
> Thanks,
> Mark
> 
> Here's the resulthandler:
>       private function jobDetailsHandler(event:ResultEvent):void {
>               jobDetails = event.result.action.item;
>               }
>       }
> 
> Here's the xml (that fails):
> <action name="jobdetaljer">
> <item>
> <id>2</id>
> <ts>05-02-2007 10:34:36</ts>
> <kid>2</kid>
> <jobnr>1046</jobnr>
> <titel>id&#65533;-nyt test job</titel>
> <beskrivelse>Visitkort idenyt</beskrivelse>
> <antal>1</antal>
> <format>sm&#65533;</format>
> <farver>2</farver>
> <papir>130g</papir>
> <oplag>1500</oplag>
> <efterbehandling>nej</efterbehandling>
> <reproinfo>ingen</reproinfo>
> <levadresse>Klausdalsbrovej 195, 2700 Herlev</levadresse>
> </item>
> </action>
> 
> And finally here's the httpservice:
>       <mx:HTTPService id="xmlJobDetaljer"
>       url = "data/xml.asp"
>       showBusyCursor="true" method="POST" result="jobDetailsHandler(event)">
>       <mx:request>
>       <action>jobdetaljer</action>
>       <jobid>
>               {jobid}
>       </jobid>
>       </mx:request>
>       </mx:HTTPService>
>


Reply via email to