WEB开发网
开发学院图形图像Flash Flex 开发入门 阅读

Flex 开发入门

 2009-01-10 11:56:00 来源:WEB开发网   
核心提示: 下面我们新建一个 Action Script 的类 J2eeServer.as 如清单 2 所示:清单 2:J2eeServer.aspackage com.ibm.flex{import flash.events.EventDispatcher;import mx.rpc.AsyncTo

下面我们新建一个 Action Script 的类 J2eeServer.as 如清单 2 所示:

清单 2:J2eeServer.as

package com.ibm.flex
{
  import flash.events.EventDispatcher;
  import mx.rpc.AsyncToken;
  import mx.rpc.events.FaultEvent;
  import mx.rpc.events.ResultEvent;
  import mx.rpc.http.HTTPService;
  
  public class J2eeServer extends EventDispatcher
  {
    public function J2eeServer()
    {
    }
    public function sendRequest(locale:String):void
    {
      var httpObject:HTTPService = new HTTPService();
      httpObject.resultFormat = "text";
      httpObject.url =
        "http://localhost:8080/FlexSample/SampleServlet?locale="+locale;
      var responder:mx.rpc.Responder = new mx.rpc.Responder(onSuccess, onFault);
      var call:AsyncToken = httpObject.send();
      call.addResponder(responder);
    }
    private function onSuccess(event:ResultEvent):void
    {
      this.dispatchEvent(event); 
    }
    
    private function onFault(event:FaultEvent):void
    {
      trace("communication failed!");
      this.dispatchEvent(event);
    }
  }
}

上一页  2 3 4 5 6 7 8 9 10  下一页

Tags:Flex 开发 入门

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接