Here ya go -- This code should work for ya.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
backgroundAlpha="0"
creationComplete="srv.send()">

<mx:Script>
     import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.utils.ObjectUtil;
[Bindable]
public var employees:ArrayCollection;

public function srv_results(event:ResultEvent):void{

   //Alert.show(ObjectUtil.toString(event.result) );
   employees = event.result.list.employee as ArrayCollection;
}
</mx:Script>

<mx:HTTPService id="srv" url="catalog.xml" useProxy="false"
result="srv_results(event)"/>

<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>

Hope this helps,

Rich

--- In [email protected], "pateyog" <[EMAIL PROTECTED]> wrote:
>
> 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::dispatchEven\
tFunction()
>  at flash.events::EventDispatcher/dispatchEvent()
>  at
>
mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal\
::dispatchRpcEvent()[C:\dev\enterprise_gmc\frameworks\mx\rpc\http\mxml\H\
TTPService.as:242]
>  at
>
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resu\
ltHandler()[C:\dev\enterprise_gmc\frameworks\mx\rpc\AbstractInvoker.as:1\
67]
>  at
>
mx.rpc::Responder/result()[C:\dev\enterprise_gmc\frameworks\mx\rpc\Respo\
nder.as:48]
>  at
>
mx.rpc::AsyncRequest/acknowledge()[C:\dev\enterprise_gmc\frameworks\mx\r\
pc\AsyncRequest.as:82]
>  at
>
DirectHTTPChannel.as$135::DirectHTTPMessageResponder/completeHandler()[C\
:\dev\enterprise_gmc\frameworks\mx\messaging\channels\DirectHTTPChannel.\
as:359]
>  at
>
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEven\
tFunction()
>  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";
> 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]</email>
>         <active>true</active>
>     </employee>
>     <employee>
>         <name>Louis Freligh</name>
>         <phone>555-219-2100</phone>
>         <email>[EMAIL PROTECTED]</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/
 



Reply via email to