\\ Home Page : Articolo : Stampa
Come inserire PHP in Flash
Di Admin (del 16/04/2007 alle 12:11:41, in Web Design , letto 2457 volte)
Ho trovato questo articolo molto interessante:

Recently, I have been experimenting with the use of php in flash, so I decided to put it to good use. So, here is the step by step guide to making a flash movie that uses php to find the user’s IP and host. A working example can be found Here.

Find the code

The php that I will be using in this project will find the user’s IP and Host address, and then print it in a way that flash understands. You can even add html to the php if you allow the “Render Text as HTML” feture in flash.

The code I will be using in the external php file is exactly as shown here. (feel free to download and edit this file, and alter it as you wish)

Which will result in this.

Notice that I have used some simple html in the code, in this case to center the content, but flash even supports the use of links in the external source, so make sure you play around.

The reason there is a “ip=” before the php is that in the flash we will add a variable “ip” to a dynamic text box, telling it to get its content from anything after the “ip=”, which in this case will be an external php file.

The creation of the flash movie

With the coding out of the way, we can get on to loading the php with the movie.

First things first, create a new blank flash document, and insert a text box, making sure it is set to “dynamic”, and has “ip” in the variable. Also, if you are planning to use html in the movie you will need to toggle on the “render text as html” option (see below).

click to enlarge

To make the php file load with the movie, click on any blank part of the slide and press “F9″ on your keyboard.

Put in the “Actions - Frame” window:

loadVariablesNum(”ip-host.php”, 0);

(Change the “ip-host.php” to the external php file that you will be using.)

actions-frame.jpg

Thats basically it. Upload the flash file and the php file to your server, and there you have it.

example.fla - 32kb
The editable flash source file.

ip-host.txt - 214b
The external php. (Rename to ip-host.php)

Any problemsà Email me, or leave a comment. This tutorial is at the tip of the iceburg; there are many more uses of php in flash, its just a case of trying them...