|
-
Switching from TXT to PHP
To get into this discussion of registering into your Flash Lite application, we need to know about SQL functions and MySQL database. The basic thing is to insert data into the database and pull the data out into it or to compare it with the user input data etc. However, to do this we need to learn/know about the database structure and the relationship of the database. This is very important that how you construct the database according to your application. In this login registration example, I will discus to construct the database to get better perform of your application on real time. Instead, to keep all the data into one database table it is always better to store data into different table of a database. This will help to organize your application and to get faster performance.
To move further of the registration section, lets change the structure of the “EMI.fla” application. Instead, to loading the “EMI.txt” text file at the beginning of the application, with all the information of the product. Lets switch the loadVariables URL path to a new php file, which checks information whether is coming from a flash application and return the value otherwise echo a warning message to the browser. This is not for a security purposes, but if someone targets the path from a browser, it returns a custom error message. This will also be a faster process to load and check from server and take the application to the right path.
firstLoadEMI.php
Change the loadVariables url path from EMI.txt to “firstLoadEMI.php”. Create a php file into the www folder of that name, and instead of loading all the information of EMI.txt, just load the information to target the flash Playhead to the “login” Frame Label. Alternatively, you can just delete all the data from EMI.txt except the last line of loaded information (&loaded=data&).
It you load the “firstLoadEMI.php” then change the 1st frame loadVariables script to the following script.
Change loadVariables Code are:
whatToDo="EMI";
loadVariables("http://localhost/firstLoadEMI.php", _root,"POST");
Here, I introduce a new variables “whatToDo” with a string value before the loadVariables and post the value to the firstLoadEMI.php file. This “whatToDo” variable will act as a condition checker and allow developers to write all the codes of login, user registration, edit user information etc. into one php file. However, for now I am doing it in separate php file, which will change later on.
firstLoadEMI.php Code:
<?PHP
//This will hide the error message
iini_set('display_errors', 0);
$whatToDo=$_POST["whatToDo"];
if($whatToDo=="EMI"){
echo "&pick=login&whatToDo=login&loaded=firstLoad&feed= firstLoad&";
}else if(!$whatToDo){
echo "<strong>Warning:</strong> Browser Does Not Support.";
}
?>
This simple code will check with the posted value from flash application and return variables information back to the flash. Here, the “else if()” condition is to print on the browser if it run from browser. The “ini_set();” script will stop displaying the actual error occur and echo the “else if()” echo script.
The preloader code of flash application which will check the firstLoadEMI.php and go to the login frame will be as follows:
Preloader Code:
iif (loaded eq feed) {
gotoAndStop(pick);
} else {
if (/:CountLoad<4) {
/:CountLoad++;
loading = loading add " .";
} else {
/:CountLoad = 0;
loading = "Loading";
}
gotoAndPlay(2);
}
This code will wait for the result from firstLoadEMI.php file from the server and jump to the frame which echoed from the php script.
continue...
marlopax
Thursday, November 19, 2009
Last edited by marlopax; 02-25-2010 at 04:10 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|