I have some simple XML which when passed to a control is displayed no
problems but when the XML only has 1 element it seems to fail.

The error I get is shown below as are my files just in case some one
has a chance to test it out.

I have a few books on Flex and they don't seem to use examples where
there is a piece of XML with just one child node, any ideas why this
error might be occuring?

TypeError: Error #1034: Type Coercion failed: cannot convert
mx.utils::[EMAIL PROTECTED] to mx.collections.ArrayCollection.
        at basic/::unitRPCResult()
        at basic/__unitRPC_result()
        at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at
mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()
        at
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()
        at mx.rpc::Responder/result()
        at mx.rpc::AsyncRequest/acknowledge()
        at ::DirectHTTPMessageResponder/completeHandler()
        at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at flash.net::URLLoader/flash.net:URLLoader::onComplete()

=== Start MXML===
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="unitRPC.send();">
        <mx:Script>
                <![CDATA[
                        import mx.collections.ArrayCollection;
                        import mx.rpc.events.ResultEvent;

                        [Bindable]
                        private var units:ArrayCollection = new 
ArrayCollection();

                        private function unitRPCResult(event:ResultEvent):void
                        {
                                units = event.result.allUnits.unit;
                        }
                ]]>
        </mx:Script>

        <mx:HTTPService id="unitRPC" url="../services/xml.xml"
result="unitRPCResult(event)" />

        <mx:ComboBox id="cmbo_test" x="10" y="10" dataProvider="{units}"
labelField="unitName"></mx:ComboBox>
        
</mx:Application>
=== End MXML===

===Start working XML===
<?xml version="1.0" encoding="utf-8" ?> 
<allUnits>
<unit>
<unitName>Bunch</unitName> 
<unitID>4</unitID> 
</unit>
<unit>
<unitName>Dozen</unitName> 
<unitID>2</unitID> 
</unit>
<unit>
<unitName>Each</unitName> 
<unitID>1</unitID> 
</unit>
<unit>
<unitName>Pound</unitName> 
<unitID>3</unitID> 
</unit>
</allUnits>
===End working XML===

===Start bad XML===
<?xml version="1.0" encoding="utf-8" ?> 
<allUnits>
<unit>
<unitName>Bunch</unitName> 
<unitID>4</unitID> 
</unit>
</allUnits>
===End bad XML===

Reply via email to