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 Variables from Flash ActionScript to PHP Tutorial

Flash ActionScript can send data to PHP files easily. The basic concept is create a new URLRequest instance to contain the variables and pass it to PHP file for processing with either sendToURL( ) method or navigateToURL( ) method. Since we wish to demonstrate the result by opening a new browser window, the tutorials will use the navigateToURL() method. It involves involves the following steps:

  1. Create A new URLVariables instance to work with to store the variable.
  2. Create variables that need to send to PHP file.
  3. Create a new URLRequest instance sending data to the specified PHP file.
  4. The data property of the request is set to the URLVariables instance to send to the PHP file.
  5. Use the navigateToURL( ) method to send data to PHP file for processing.

The process of sending data from Flash ActionScript to PHP file can be illustrated with the following diagram:

flash actionscript 3 php communication

Flash ActionScript Codes:

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

 

// Create a variable (e.g. candidate) to send
myVariables.candidate = "Alex";

 

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

 

// The data property of the request is set to the
// URLVariables instance (myVariables) to send to the PHP file.
myRequest.data = myVariables;

// Use the navigateToURL( ) method to send data to PHP file for processing
navigateToURL(myRequest, '_blank');

 

Remarks:

This Flash ActionScript PHP tutorial discuss how to send data from Flash AS to PHP.