<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute" 
    applicationComplete="{initApp()}" pageTitle="AWI Simple Client" viewSourceURL="awiClientSample.mxml">
    <mx:Script>
        <![CDATA[
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;
            public function initApp():void
            {
                awi.getFullArchives.send();
                awi.getRecentPosts.send(25);
            }
            public function RemoteFault(event:FaultEvent):void
            {
                trace("Error "+event)
            }
            public function onGetRecentPosts(event:ResultEvent):void
            {
                out.dataProvider = event.result
            }
            public function onGetFullArchives(event:ResultEvent):void
            {
                tree.dataProvider = event.result
            }
            public function treeChanged(event:Event):void {
                var tree:Tree = event.target as Tree
                var sNode:Object = tree.selectedItem;
                 //call some method
            }
        ]]>
    </mx:Script>
    <mx:RemoteObject id="awi" destination="amfphp" fault="{RemoteFault(event)}" source="awi.awiClient" showBusyCursor="true">
        <mx:method name="getFullArchives" result="{onGetFullArchives(event)}" />
        <mx:method name="getRecentPosts" result="{onGetRecentPosts(event)}" />
    </mx:RemoteObject>
    <mx:Tree width="158" id="tree" labelField="title" right="10" top="10" bottom="10" change="{treeChanged(event)}"/>
    <mx:DataGrid id="out" left="0" right="175" bottom="10" top="10"/>
</mx:Application>