Hi friends, I am back with another Adobe Flash Tutorial, today we are going to learn about how to use flash as a two way and how to use it for PHP communication. I have also posted a video of this entire procedure, here it is.
In this flash, Action Script 3 Lesson, we going to demonstrate how you can communicate between, in flash action script 3 and PHP in a two way communication. Example. All these files, the PHP files, FLV files, and everything you need, this is in a free download on the page, where this tutorial is, developphp.com. And you can go there download it free, and that way you can get to all the files to see it working yourself once you put it on server. And remember PHP wont process locally. PHP has to be on server equipped and ready to handle PHP files, whether it be in your local environment on your Windows and Mac machine. You have to have PHP setup on windows and Mac machine to work locally and out of the web. But if you posted it on the web, you tested your files on the web, you see that the most host servers, process PHP automatically. Therefore, it would work on the web, if you tried on your local machine or on a local Mac, windows machine then probably won’t work on unless you have PHP configured to run on your local machine.
So lets talk about the FLV files. First what happens is, it sends a, lets see if I can go to, open up a form in the web, okay here it is in browser, and I wanna put my name in, Adam, I will press submit. And says ‘the name field with the variable of Adam has been sent PHP and is back. Adam is also set in variable 2 in PHP. So this is variable 1 the text field and this is variable 2 here. So we will be showing, back to variable from the PHP files. And I will show the PHP file right now. Let me show you if I type in, David, file submit. It all change. It will send another request to server, and it will process another PHP file. And when the variable back out, you can see how the David is here. so if you use the form on the site, in the demo, you will see that it will change those names just in time when you hit it. Write Sarah, and it changes the names every time. So, you can see the communication happening. So that’s what happens, when the users using it and the files in the action script.
I have it all pretty well collected, what it does there. and just set up the URL request, and URL loader, and since variables, we set up the URL variables here. and we poped them in to the values, name in pairs. There two written right here, that will go get posted, in to the PHP file. And you put the URL to the reference location, towards the PHP file living on your server, right here in this line. And here is where we put the two variables that we get back from PHP. You put them in to the local variables in flash here. you then bring then out into the text fields. Right here and right here. And you see that its a name of results 1 text and result 2 text.
Lets see, look at the PHP file, now. And php when you look at it, as you download everything, you will see its commented above, I commented the lines with both, waiting to happening. And If you see that the first line, checks to see if its sent, the script will only run if its sent from the request sent from the flash, so it wont run, if somebody go directly to it on the server. If they navigate through this page. And what happens is after we found if its sent from flash everything is okay, then we put the username, in to local variable in PHP. And then we print out variable one, and then the printouts it’s a; we print out variable 1, and its variable here. And then we put the enter sign here, we add variable 2 to the string going into flash, and its value is here. you can see how we use, the variable username here. Or you name right there. and we put it right there in sense in that as to sent back to flash. And there is the form of two variables. And if you wanna put more, you can easily put more. You just have to passes them back to the flash. Okay so lets see that, and I think that’s about everything.
Its not too complicated but it’s a little, little complicated. But want you to do couple of times, it makes a log in form, a contact form, site registration form, anything that PHP would handle. May be you want to sent data to MySQL, get data from MySQL database according to what it sent. you can do that. Many many things you can do with this type of programming in flash. So what I use it for, usually, is for have PHP communication with my SQL database and vendor out the dynamic data. That is what usually I use this kind of coding in flash. This is a kind of actionscritp 3.
Okay, see you guys in next lesson.
Tags: flash cartoon tutorial, free macromedia flash, flash beginner tutorial, flash game, adobe macromedia flash player download, download macromedia flash, flash navigation tutorial
Related Articles
No user responded in this post
Leave A Reply
Please Note: Comment moderation maybe active so there is no need to resubmit your comments