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

Flash ActionScript Send Multiple Variables to PHP Tutorial

The previous Flash ActionScript 3 PHP communication tutorial shows how to send a single variable from ActionScript to PHP. In most cases, multiple variables will be sent from AS to PHP.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

This Flash ActionScript PHP communication tutorial shows how to send multiple variables from Actionscript to PHP.

The Flash Movie of this tutorial is shown as above.

PHP File Codes:

<?php

echo "The variables sent from Flash ActionScript are: " . $_GET["candidate"] . " and " . $_GET["jobTitle"];

?>

The output of the PHP file will get the name-value pairs variable from the URL.

Flash ActionScript Codes:

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

 

// Create variables (e.g. candidate, jobTitle) to send
myVariables.candidate = "Alex";
myVariables.jobTitle = "Flash Designer";

 

// 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.
// Note: myVariables stored the variable (e.g. candidate)
myRequest.data = myVariables;

 

function sendVariable (evt:MouseEvent):void {



// Use the navigateToURL( ) method to send data to PHP file for processing
// Also display the output in a new browser
navigateToURL(myRequest, '_blank');


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

Download Flash Source File:

Flash Source File as3-php-communication-22.fla

Remarks:

This Flash ActionScript tutorial shows how to send multiple variables from AS to PHP.