DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Kalatravas has posted 29 posts at DZone. View Full User Profile

Actionscript 3 : Sending Name/value Pairs To A Server Side Script With The URLVariables Class

09.16.2010
| 2580 views |
  • submit to reddit
        // description of your code here


//www.tournasdimitrios1.wordpress.com

import flash.events.Event;
import flash.net.*;

var myRequest:URLRequest = new URLRequest("http://www.myserver.com/myscript.php");
myRequest.method = URLRequestMethod.GET;
var myLoader:URLLoader = new URLLoader();
var myVariables:URLVariables = new URLVariables();
myVariables.firstProperty = "first";
myVariables.secondProperty = "second";
myRequest.data = myVariables;
function onLoaded(evt:Event):void {
  trace("here we get the data back: "+myLoader.data);
}
myLoader.addEventListener(Event.COMPLETE, onLoaded);
myLoader.load(myRequest);

// send an XML file to your server side script 


import flash.events.Event;
import flash.net.*;

var myRequest:URLRequest = new URLRequest("http://www.myserver.com/myscript.php");
myRequest.contentType = "text/xml";
myRequest.data = myXML;
var myLoader:URLLoader = new URLLoader();
var myXML:XML = Hello World;

function onLoaded(evt:Event):void {
  trace("here we get the data back: "+myLoader.data);
}

myLoader.addEventListener(Event.COMPLETE, onLoaded);
myLoader.load(myRequest);