|
 |
|
|
|
|
|
SWiSH MAX Communicating with PHP
Assumption
It is assumed that the reader has knowhow to create an input textbox
or a dynamic textbox in SWiSH MAX.
[quote]
Remember : The text object name and variable name must be different
from eachother.
e.g.
Object Name : mytextobj
Variable Name : mytext
NOTE : If you don't know how to attach variable with a text
object, then CLICK HERE
[/quote]
What is this Tutorials for?
This tutorial demonstrates : how to send information from SWiSH MAX
to a PHP script; and response back from PHP script to SWiSH MAX.
TUTORIAL STARTS
There are two methods of sending information on HTTP protocol (GET and POST).
Both of the methods may be used in SWiSH MAX to send information.
A function loadVariables() is used for doing so.
In this function you specify the script file (e.g. myfile.php), method
to be used (GET or POST), and level (from where) to send information.
[quote]
If you do not have knowledge of variables, '_root', '_parent', and 'this',
then CLICK HERE.
[/quote]
Now we will create a small SWiSH MAX applciation which will send a vaiable
(containing text data) to the PHP script, the script will response back, and
the response back text shown in SWiSH MAX ill be reverse ordered of actual.
Here are some steps to do this
Follow the Steps:
- Open new SWiSH MAX movie
- Create an input textbox
- Set text Object name 'myobj'
- Set text Object variable name to 'myvar'
- Create a simple button
- Select the button and goto script window
- Write SWiSHScript in
| CODE |
on(release) {
loadVariables("myfile.php",'POST');
}
|
- Create a new text file in notepad and save as 'myfile.php'
tip : while saving file use file name with quotes, e.g. "myfile.php"
- Write PHP code in file 'myfile.php' as
| CODE |
<?
$newvalue = strrev($myvar);
echo "&myvar =$newvalue";
?>
|
[quote]
Tip : The '&' sign specifies that the data for preceeding variable (if applicable) has ended
and a new variable's data starts.
[/quote]
- Export your html, but remember to set SWF version to 6 from 'Export' property tab
- upload files to some server (supporting PHP, or you may test on localhos, if
apache webserver is installed on your system)
- Now its done, open your html file from specific url.
|
|
|
|