R – AS3 Passing and getting data to ASP

actionscript-3asp.net

I've been researching for days on the issude but till now I still haven found a solution yet.
I have 0 knowledge on ASP. And I just want to able to pass and get var/text from ASP.

Anyone kind enuff to guide me how I can furthur from here?

private function loadASP():void {
        var aspSend:URLRequest=new URLRequest("testASP.asp");
        var aspLoader:URLLoader = new URLLoader();

        aspLoader.load(aspSend);

        trace("did send");
        //aspLoader.addEventListener(Event.COMPLETE, processASP);
    }

    private function processASP(e:Event):void {
    }

Best Answer

Why have you commented the call to addEventListener method? Uncomment it (and move it up two lines so that it comes before the load call). If the url is correct, the processASP method will be called when the response arrives (in a real life application, make sure you listen for ioError and securityError on the URLLoader - check the link for examples on doing this). You can read the response as e.target.data in the processASP method.

private function processASP(e:Event):void 
{
  var loader:URLLoader = URLLoader(e.target);
  trace("Response is " + loader.data);
}

URLLoader can also be used to send data to the asp page (server).

var ldr:URLLoader = new URLLoader();
var data:URLVariables = new URLVariables();
data.something = "someData";
data.somethingElse = "moreData";
var request:URLRequest = new URLRequest("url.asp");
request.data = data;
request.method = URLRequestMethod.POST;//or GET
ldr.addEventListener(Event.COMPLETE, onLoad);
//listen for other events
ldr.load(request);
Related Topic