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 Single Variable to PHP Tutorial

This Flash ActionScript 3 PHP communication tutorial shows how to send a single variable from ActionScript to PHP.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

This is a basic Flash ActionScript PHP communication tutorial. It only send a single variable from Actionscript to PHP.

The Flash Movie of this tutorial is shown as above.

PHP File Codes:

<?php

echo "The varaiable sent from Flash ActionScript is: " . $_GET["candidate"];

?>

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 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.
// 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-21.fla

Remarks:

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