Connecting To PHP

When Connecting to external php scripts, I learned how to construct a load funtion that would request the URL location that is defined in the URLRequest() function.

var logOutVars:URLVariables = new URLVariables();
var logOutURL:URLRequest = new URLRequest(“http://www.dandesigningweb.co.uk/test.php”);//log out script amd loader
    logOutURL.method = URLRequestMethod.POST;
    logOutURL.data = logOutVars;

I learned that this reads and gathers text that is loaded on screen and the information is structured with names, separated by the and symbol &.

firstname=danny&lastname=whittaker&gender=male

I found this similar to the $_GET and $_POST method used in HTML forms. My problem was that i will be using multiple firstnames, lastnames and so on. This meant that i would need each name identify to be different because i would need to target a particular name or information.

I then research different loops to suit what i needed. I found the “FOR” loop. This loops data set on a condition that i command.

for($i = 0; $i<= $amount; $i++)
     {
    echo ‘fistname’ . $i . ‘=’ . $fname ;
     }

I first counted the rows retrieved from the request. This then sets the amount for the loop to cycle. The $i auto increments for each loop this is then added to the target name of each piece of data.

this will display like this

firstname0=dan&lastname0=whittaker
firstname1=tara&lastname1=jackson
firstname2=ben&lastname2=mell
 The i used this method in flash actionScript 3 to retrieve the data
for(var i:uint=0; i<FriendNum; i++)
     {
     NameArray[i].text  = evt.target.data[“firstname”+i];                          
     }
by using the same method i found that “i” would create each name. I also pulled the amount of rows across to create the correct amount of loops.

I then found that when i created each movieClip and added the instance to the stage they was placed on top of each other.

I then realized that if i place its Y postion, by ‘height’  X ‘$i’ it will position each movieClip on top of each other.

 mcArray[i].y = h * i;// x height by amount to stagger positions

This allowed me to use dynamic data and stagger content to create lists. I used this to display messages, friends list and so on.