Using httpservice in Flex/Actionscripts passing XML file with only one item

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

I encountered a problem with passing xml file to Flex using Httpservice.
If the XML file I pass to the flex has only one item, e.g.:

<DATA>

<SoftwareName>Photoshop </SoftwareName>

</DATA>

Then if you use an arraycollection to save the data.

e.g.

[Bindable]
public var SoftwareData:ArrayCollection;

[Bindable] public var SoftwareData:ArrayCollection;

http://casario.blogs.com/mmworld/2006/07/arraycollection.html

<s:HTTPService id=”getSoftware” url=”{SoftwareServer}” result=”getSoftware_resultHandler(event)” fault=”getSoftware_faultHandler(event)”  />

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

if we use “SoftwareData=getSoftware.lastResult.DATA.Software; “, it will not work for only one item.

The solution is :

if(getSoftware.lastResult.DATA.Software==null)

{ Alert.show(“No record”); }

else if(getSoftware.lastResult.DATA.Software is ObjectProxy)

{ SoftwareData=new ArrayCollection([getSoftware.lastResult.DATA.Software]); }

else{SoftwareData=getSoftware.lastResult.DATA.Software as ArrayCollection; }

Reference:  from a guy called chunk

http://casario.blogs.com/mmworld/2006/07/arraycollection.html

Read More