Skip to content

Instantly share code, notes, and snippets.

@moondev
Last active December 11, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moondev/4542709 to your computer and use it in GitHub Desktop.
Save moondev/4542709 to your computer and use it in GitHub Desktop.
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequestMethod;
import flash.events.Event;
submitbtn.addEventListener(MouseEvent.CLICK, sendData)
function sendData(event:MouseEvent):void
{
// Create the POST request test.php would actually be /send.php in your version
var request:URLRequest = new URLRequest("test.php");
request.method = URLRequestMethod.POST;
// Create the variables object that contains what is sent to the php script
var vars:URLVariables = new URLVariables();
//this array will hold all of our part objects
var partList = [];
//add a part. you can use whatever you want attribute names.
partList.push({
'partName' : 'leftSide',
'width' : '12',
'height' : '10',
'type' : 'closed',
'orientation' : 'vertical'
});
//add another
partList.push({
'partName' : 'door',
'size' : '5x7',
'cuts' : 'none',
'motor' : 'none'
});
//add another part
partList.push({
'partName' : 'door',
'size' : '10x4',
'cuts' : '45',
'motor' : 'yes'
});
//serialize array so we can send it in a POST
vars.parts = JSON.stringify(partList);
//add to the post data for sending
request.data = vars;
//post to page!
navigateToURL(request, "_self");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment