RSS Home Newsletter Advertising
Visit Twellow.com

Working with Flash MX 2004and PHP

This tutorial is going to show you a very basic method of sending information from Flash to an external PHP script. Thisis merely a primer to get you working with using Flashfor forms and dynamic content.The actual code for this tutorial can be used IN lower versions of Flash, but the actual process is written for Flash MX 2004.

Here is the example that we are going to create - http://flashnewz.com/examples/namesubmission.html

Creating the Flash Document To begin our tutorial we are going to create our Flash document. Open Flash and create a new Flash document. On the stage take your text tool and draw a text box. Now highlight the text box and hit F8 so we can convert our text box to a symbol. We are going to change our text box into a button. The reason we are doing this is so we can add the "Hit Enter Key" function so the user can simply hit enter rather than having to press the submit button. Once you have converted the text box to a symbol double click the text box so we can edit the text box. In the variable area type in "name". This is going to be used when sending information to our PHP script. Now go back to our main stage area, where we will add our "Hit Enter Key" actions. Open your actions panel and select your text box. In your actions panel under Global Functions/Movie Clip Controls double click the "on"  and select keyPress "<Enter>". In the actions pane click before the } tag because our getURL command has to come before the close of the actionscript. Under Global Functions/Browser/network double click the getURL action. Now in our actions we are going to add a link to our php script, window, and method. I named my PHP name.php. Make sure that you use the GET method for this example. Here is what your actionscript should look like: This completes the textbox area of our FlashMovie. To add another button so the user can click as I have added in my Flash movie you simply repeat this process, but use the on (release) function. Now export your movie. =================================================== Now it's time for our PHP script.  Since the PHP is so simple for this example I am going to paste the code and let you copy it, name it name.php and let you use it from there. <html> <body> <p>Hello <span class="style1"><? echo $_GET['name'];?></span>,</p>           <p>As you can see, our Flash movie has sent the information you entered into the text field to the PHP script displayed here.<br>           </p>      </body> </html> Notice that we used "name" in our php script to reflect the variable in our Flash movie? If you change the variable name in our Flash move we also need to change the value in our php script. Now upload both of them and test it out. If we did everything properly the SWF file should send the information to the PHP script, which will show the name once the user submits the data. If you have any questions or comments feel free to send me an email!

Having created the outlines for FlashNewz and FLADownloads, John has become a strong voice in the Flash Community. His reviews and tutorials give great insight and knowledge to readers around the world. He has a keen eye for what's hot and what's not in the Flash world. He has also developed and continues to run his own flash portal as a side project to keep his mind on the Flash community

Being a key designer for advertising creative, he's got style when it comes to grabbing readers attention. With a proven track record, there isn't much this guy can't handle.

Digg This! StumbleUpon This!


News Tags: PHP, HTTP, Email, Flash
About the author:
Having created the outlines for FlashNewz and FLADownloads, John has become a strong voice in the Flash Community. His reviews and tutorials give great insight and knowledge to readers around the world. He has a keen eye for what's hot and what's not in the Flash world. He has also developed and continues to run his own flash portal as a side project to keep his mind on the Flash community

Being a key designer for advertising creative, he's got style when it comes to grabbing readers attention. With a proven track record, there isn't much this guy can't handle.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
10 + 6 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Subscribe to WebProNews


Send me relevant info