try adding
import mx.utils.ArrayUtil;
and calling toArray():
<mx:HTTPService id="srv" url="employees.xml" useProxy="false"
result="employees = new
ArrayCollection(ArrayUtil.toArray(srv.lastResult.list.employee))"/>
hth,
matt horn
flex docs
> -----Original Message-----
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of pateyog
> Sent: Tuesday, August 01, 2006 11:44 AM
> To: [email protected]
> Subject: [flexcoders] problem using httpservice to fetch xml
>
> I am facing a problem with a code which used to work with
> flex beta 2.0 but has stopped working when I moved to the
> release version. I get the following error while executing
> the below given code:
>
> TypeError: Error #1034: Type Coercion failed: cannot convert
> mx.collections::[EMAIL PROTECTED] to Array.
> at
> GridBindingDemo/__srv_result()[D:\dev\8J-Flex\GridBindingDemo.mxml:16]
> at
> flash.events::EventDispatcher/flash.events:EventDispatcher::di
> spatchEventFunction()
> at flash.events::EventDispatcher/dispatchEvent()
> at
> mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/m
> x/internal::dispatchRpcEvent
> <http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent>
>
> ()[C:\dev\enterprise_gmc\frameworks\mx\rpc\http\mxml\HTTPServi
ce.as:242]
> at
> mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/inte
> rnal::resultHandler
> <http://www.adobe.com/2006/flex/mx/internal::resultHandler>
> ()[C:\dev\enterprise_gmc\frameworks\mx\rpc\AbstractInvoker.as:167]
> at
> mx.rpc::Responder/result()[C:\dev\enterprise_gmc\frameworks\mx
> \rpc\Responder.as:48]
> at
> mx.rpc::AsyncRequest/acknowledge()[C:\dev\enterprise_gmc\frame
works\mx\rpc\AsyncRequest.as:82]
> at
> DirectHTTPChannel.as$135::DirectHTTPMessageResponder/completeH
andler()[C:\dev\enterprise_gmc\frameworks\mx\messaging\channels>
\DirectHTTPChannel.as:359]
> at
> flash.events::EventDispatcher/flash.events:EventDispatcher::di
> spatchEventFunction()
> at flash.events::EventDispatcher/dispatchEvent()
> at flash.net::URLLoader/flash.net:URLLoader::onComplete()
>
>
> The flex app
> ============
> <?xml version="1.0" encoding="utf-8"?>
>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
> <http://www.adobe.com/2006/mxml> "
> backgroundAlpha="0"
> creationComplete="srv.send()">
>
> <mx:Script>
>
> import mx.collections.ArrayCollection;
>
> [Bindable]
> public var employees:ArrayCollection;
>
> </mx:Script>
>
> <mx:HTTPService id="srv" url="employees.xml" useProxy="false"
> result="employees = new
> ArrayCollection(srv.lastResult.list.employee)"/>
>
> <mx:HBox width="100%" height="100%">
>
> <mx:DataGrid id="dg" width="100%" height="100%"
> dataProvider="{employees}">
> <mx:columns>
> <mx:Array>
> <mx:DataGridColumn dataField="name"
> headerText="Name"/>
> <mx:DataGridColumn dataField="phone"
> headerText="Phone"/>
> <mx:DataGridColumn dataField="email"
> headerText="Email"/>
> </mx:Array>
> </mx:columns>
> </mx:DataGrid>
>
> <mx:Form width="100%" height="100%">
> <mx:FormItem label="Name">
> <mx:Label text="{dg.selectedItem.name}"/> </mx:FormItem>
> <mx:FormItem label="Email"> <mx:Label
> text="{dg.selectedItem.email}"/> </mx:FormItem> <mx:FormItem
> label="Phone"> <mx:Label text="{dg.selectedItem.phone}"/>
> </mx:FormItem> </mx:Form>
>
> </mx:HBox>
>
> </mx:Application>
>
> The employees.xml used
> ============
> <?xml version="1.0" encoding="utf-8"?>
>
> <list>
>
> <employee>
> <name>Christina Coenraets</name>
> <phone>555-219-2270</phone>
> <email>[EMAIL PROTECTED]
> <mailto:ccoenraets%40fictitious.com> </email>
> <active>true</active> </employee> <employee> <name>Louis
> Freligh</name> <phone>555-219-2100</phone>
> <email>[EMAIL PROTECTED]
> <mailto:lfreligh%40fictitious.com> </email>
> <active>true</active> </employee>
>
> </list>
>
>
>
>
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/