Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

Send Multiple Input Data from Flash ActionScript to PHP and Returned Back

This Flash ActionScript 3 and PHP tutorial shows how to send more than one input data from ActionScript to PHP and return back to PHP.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

In this Flash ActionScript PHP communication tutorial, two input data is sent to the PHP file. Actually any number of input data can be sent in the same way.

The Flash Movie of this tutorial is shown as above.

PHP File Codes:


// variables send from Flash Actionscript
$candidate = $_POST['candidate'];
$post = $_POST['post'];

// Confirm to Flash ActionScript that the data has been received
echo "phpConfirm1=Greeting " . $candidate . "! I got your data. Thanks";
echo "&phpConfirm2=Yes, your position is " . $post;


The output of the PHP file is "phpConfirm1=Greeting Alex! I got your data. Thanks&phpConfirm2=Yes, your position is Flash designer.".

Flash ActionScript Codes:

function checkComplete(evt:MouseEvent):void {

// Create A new URLVariables instance to store the variable
var myVariables:URLVariables = new URLVariables();

// Create variables (e.g. candidate and post) to send
myVariables.candidate = candidate_txt.text;
myVariables.post = post_txt.text;

// Create a new URLRequest instance sending data to "ascom01.php"
var myRequest:URLRequest = new URLRequest("ascom01.php");

// Send data using the POST method
myRequest.method = URLRequestMethod.POST;

// The data property of the request is set to the
// URLVariables instance (myVariables) to send to the PHP file.
// Note: myVariables stored the variable (e.g. candidate)
myRequest.data = myVariables;

// Create a new instance of the URLLoader class to work with.
// URLLoader.load( ) method should be used when we need the
// sent variables returned back to Flash ActionScript.
var myLoader:URLLoader = new URLLoader;

//specify dataFormat property of the URLLoader to be "VARIABLES"
//This ensure that the variables loaded into Flash with the same variable names
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

//Load the PHP file by using URLRequest

//Listen when the loading of data COMPLETE
//Call the loadComplete function when the loading COMPLETE
myLoader.addEventListener(Event.COMPLETE, loadComplete);



// Hook up the button with the function checkComplete
enter_btn.addEventListener(MouseEvent.CLICK, checkComplete);

// This is the function that display the data returned back from PHP file
function loadComplete(evt:Event):void {

//Display the value with variable name "phpConfirm1" and "phpConfirm2"
output_txt.htmlText = evt.target.data.phpConfirm1 + "<br>" + evt.target.data.phpConfirm2;



Download Flash Source File:

Flash Source File as3-php-two-communication-03.fla


This Flash ActionScript tutorial shows how to send input data from Actionscript to PHP and return back.