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

Pass PHP Variable Output to Flash ActionScript Tutorial

This Flash ActionScript PHP tutorial series shows how to pass PHP variable output to AS. The procedures are quite similar as the Flash ActionScript loading external text files with variables. It also involves involves the following steps:

  1. Create a new instance of the URLLoader class to work with.
  2. Specify dataFormat property of the URLLoader to be "VARIABLES".
    (Need to parse the data of the external text file contained name-value pairs variable, for example, Candidate=Alex&Post=Production Engineer)
  3. Create a new URLRequest object specifying the location or URL of the PHP file.
  4. Load the PHP file by using URLRequest
  5. Display the output of the PHP file.

The Flash ActionScript and PHP communication can be illustrated with the following diagram:

flash actionscript 3 php communication

Flash ActionScript Codes:

//Create a URLLoader object with the name myLoader
var myLoader:URLLoader = new URLLoader();

 

// Specify dataFormat propery of the URLLoader to be "VARIABLES"
// This ensure variables loaded into Flash with same variable names

myLoader.dataFormat = URLLoaderDataFormat.TEXT;

 

// Create a new URLRequest object
// specifying the location or URL of the external text file.
var myRequest:URLRequest=new URLRequest("story.txt");

 

// Call the load( ) method to load the external file
// with the URLRequest object as the parameter.

myLoader.load(myRequest);

 

// Display the value with variable name, for example, "Candidate"
output_txt.text = evt.target.data.Candidate;

 

Remarks:

This Flash Actionscript 3 PHP communication tutorial discuss how to pass PHP variables to AS.