<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http: layout="absolute" creationComplete="initApp()">
<mx:Script>
<![CDATA[
include "employees.as";
]]>
</mx:Script>
<mx:HTTPService
id="employeesService"
url="http:
resultFormat="e4x"
result="resultHandler(event)" />
<mx:ViewStack id="viewstack1" width="100%" height="100%" >
<mx:Canvas label="Form View" width="100%" height="100%">
<mx:Form horizontalCenter="0" verticalCenter="0" backgroundColor="#FFFFFF">
<mx:FormItem label="Query Employees ">
<mx:Button label="Submit" click="fill()" width="100"/>
</mx:FormItem>
</mx:Form>
</mx:Canvas>
<mx:Panel label="DataGrid View" width="100%" height="100%">
<mx:DataGrid width="100%" height="100%" dataProvider="{result.employee}">
<mx:columns>
<mx:DataGridColumn dataField="firstName" headerText="First Name"/>
<mx:DataGridColumn dataField="lastName" headerText="Last Name"/>
<mx:DataGridColumn dataField="officePhone" headerText="Phone"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:ViewStack>
</mx:Application>
Try this code (I removed some unnecessary code like the call to the cancel() method and the user of hte params object). I also put it in a single file for clarity, but you can break out the ActionScript to a separate script file if you want.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
[Bindable]
private var r:XML;
public function fill():void {
viewstack1.selectedIndex=1;
employeesService.send();
}
public function resultHandler(event:ResultEvent):void {
r = XML(event.result);
}
]]>
</mx:Script>
<mx:HTTPService id="employeesService" useProxy="false" method="POST" url="http://www.flexmonkeys.com/F3GSE/PartIII/CRUD/employees.xml" resultFormat="e4x" result="resultHandler(event)" />
<mx:ViewStack id="viewstack1" width="100%" height="100%" >
<mx:Canvas label="Form View" width="100%" height="100%">
<mx:Form horizontalCenter="0" verticalCenter="0" backgroundColor="#FFFFFF">
<mx:FormItem label="Query Employees ">
<mx:Button label="Submit" click="fill()" width="100"/>
</mx:FormItem>
</mx:Form>
</mx:Canvas>
<mx:Panel label="DataGrid View" width="100%" height="100%">
<mx:DataGrid width="100%" height="100%" dataProvider="{r.employee}">
<mx:columns>
<mx:DataGridColumn dataField="firstName" headerText="First Name"/>
<mx:DataGridColumn dataField="lastName" headerText="Last Name"/>
<mx:DataGridColumn dataField="officePhone" headerText="Phone"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:ViewStack>
</mx:Application>
hth,
matthew j. horn
flex docs