Skip to content
cristobal edited this page Sep 14, 2010 · 5 revisions

Description

HTTPService for AS3 tries to mimic the mx.rpc.http.HTTPService behaviour for AS3 only classes.
It does so by wrapping the flash.net.URLLoader & flash.net.URLRequest classes as it where one class.

Example

Using the class to load xml should be as simple as:

import com.net.http.HTTPService;
import com.net.rpc.events.ResultEvent;
import com.net.rpc.events.FaultEvent;

/**
 * Complete handler
 */
function onComplete(result:ResultEvent):void {
  trace("Successfully loaded xml:");
  trace(event.result);
}

/**
 * Fault handler
 */
function onFault(event:FaultEvent):void {
  trace("Could not load xml");
  trace(event.fault);
}

/* Initialize and set parameters*/
var httpService:HTTPService = new HTTPService();
httpService.url = "http://example.com/destionation.xml";
httpService.method = HTTPService.REQUEST_METHOD_POST;
httpService.resultFormat = HTTPService.RESULT_FORMAT_XML;

/* Add Event listeners */
httpService.addEventListener(ResultEvent.RESULT, onComplete);
httpService.addEventListener(FaultEvent.Fault, onFault);

/*  Send the request */
httpService.send();
Clone this wiki locally