Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

  

 

 

 

 

 
Displaying
Flash Data in PHP
        by j. edick. aka jubba

This is a fairly simple technique that uses a simple setup that will send variables from a Flash movie to a PHP script, and then that PHP script will print the variables out.

Flash Player set-up
First you need to set up the input boxes. Create an Input box by using the "Text tool" In the text properties box, you must give the input box a name. It doesn't matter what the name is, but you must remember that name because we are going to be using it in the PHP script in a few minutes.

In my file I made three input boxes. I named them "name", "age", and "eye". Simple enough right? Ok, now we have to make the button to open up the PHP page. To open up a new page from Flash we use getURL(). The code that I used looks like this:

submit.onPress = function () {
      
getURL ("getVars.php""_blank""POST");
}

Explanation:

  • getVars.php is the name of the PHP file that is our target.

  • _blank makes the button open up a new page.

  • POST is the method in which to transfer the variables. The other option is GET.
     

PHP Page set-up
The PHP code is simple:

<?
// Receiving the variables.
$name $_POST['name'];
$age $_POST['age'];
$eye $_POST['eye'];

// Printing out the variables.
print "Your name is "$name ".";
print 
"You are "$age ." years old.";
print 
"You have "$eye ." eyes.";
?>
 

Now a quick explanation of the code:

The first three lines receive the variables from the scripting using $_POST[]; This is necessary because the more recent versions of PHP have global variables turned off by default. On some hosts, your script will not work without using this method. You can name the variable whatever you like on the left of the equal sign ("="), but on the right, you must put the variable of your input text box.

The second 3 lines print out the strings. The extra periods (".") in there are used to connect the strings together. Its called the concatenation operator. For more about that go here: Click Here!

To see this script in action, go here: Click Here!

For any help, please post on the forums.

Cheers,
Jubs

 




SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple.