天天看點

學習筆記-Flex 之登入界面

<?xml version="1.0" ?>
<!-- Simple example to demonstrate the States class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Style>
Application {
fontSize:12pt;
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
//資料傳回成功的處理,本例中不适用這個方法處理結果,而是直接通過lastresult邦迪給控件
private function onresult(e:ResultEvent):void
{
trace("onResult");
}
private function onFault(e:ResultEvent):void
{
ta.text="讀取資料錯誤,請稍後再試";
btnSearch.enabled=true;
}
private function search():void
{
btnSearch.enabled=false;
myws.getMostPopularPosts.send();
}
]]>
</mx:Script>
<mx:WebService id="myws" wsdl="http://feeds.adobe.com/webservices/mxna2.cfc?wsdl" showBusyCursor="true">
<!--定義WebService的方法-->
<mx:operation name="getMostPopularPosts" result="onresult(event)" fault="onFault">
<!--調用方法是傳遞的參數。tag名稱就是參數名稱-->
<mx:request >
<dayBack>10</dayBack>
<limit>10</limit>
</mx:request>
</mx:operation>
</mx:WebService>
<!--定義WebService-->
<mx:Panel >
<mx:Button id="btnSearch" label="檢視" click="search()" />
<!--DataGrid 顯示結果,直接将結果綁定給DataProvider-->
<mx:DataGrid id="grdResult" x="97" y="10"
dataProvider="{myws.getMostPopularPosts.lastResult}">
<mx:columns>
<mx:DataGridColumn headerText="最熱主題" dataField="postTitle"/>
<mx:DataGridColumn headerText="點選數" dataField="clicks" width="75"/>
</mx:columns>
</mx:DataGrid>
<mx:TextArea id="ta" x="12" y="71" width="500" height="100" editable="false" text="{grdResult.selectedItem.postExcerpt}"/>
</mx:Panel>
</mx:Application>