<em id="hanht"></em>

    <dd id="hanht"></dd>

    <em id="hanht"><acronym id="hanht"></acronym></em>
    
    <button id="hanht"></button>
    <rp id="hanht"><object id="hanht"><blockquote id="hanht"></blockquote></object></rp><em id="hanht"></em>

    首頁 > 設計 > WEB開發 > 正文

    21.2.處理Web Services調用結果

    2023-08-14 18:53:58
    字體:
    來源:轉載
    供稿:網友
    問題
    我想接收web services 方法的返回值
    解決辦法
    監聽web services 對象的result 事件
    討論
    Web services 方法的類型實際上是mx.rpc.soap.Operation,當web services 方法返回值時,方法對象會發出mx.rpc.events.ResultEvent 事件,要想處理這個事件可注冊監聽器,例如,webService有個方法叫getAverages( ),可這樣注冊監聽器:
    +展開
    -ActionScript
    webService.getAverages.addEventListener(ResultEvent.RESULT, onGetAverages);

    調用寫法和其他方法一樣:
    +展開
    -ActionScript
    webService.getAverages( );

    當進入處理函數時,會傳進來一個ResultEvent 參數,ResultEvent 類定義了一個叫result 的屬性,它包含返回值,因為getAverages( ) 方法返回一個關聯數組,包含兩個屬性:flash 和actionscript:
    +展開
    -ActionScript
    private function onGetAverages(event:ResultEvent):void {
    textArea.text = "The averages for Flash and ActionScript are " +
    event.result.flash + " and " + event.result.actionscript;
    }
    發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表