Using PHP variables in AS

Ok I’ve trolled around as much as I can and am still unable to get this to work, so thought I’d bite the bullet and make yet another post :slight_smile:

my script is connecting to an external PHP file. The php file is collecting info from a database and then printing them as a variable that flash can display. The database is a member database and is using an IF statement to draw out a select few from this database who are linked as being part of the “Watcher” guild. So, the database parses two main bulks of variables to flash:

Count - the amount of members who are part of the “Watcher” guild
WatcherXXX - where XXX is replaced with the number gained from count.

I.E. the following info is parsed:

count = 3
watcher1 = bob
watcher2 = blah
watcher3 = hohoho

Thats the PHP bit. I’m then using the following AS to collect that data and dump it into a movieclip:

onClipEvent (load) {
loadVariables(“flash_test.php”, this, “GET”);
}

The movie clip then uses the info collected from the PHP file and dynamicaly creates dynamic text fields and deposits each of the “watcherXXX” variables into the text field:

//make textboxes
for(i=1;i<=10;i++){
_root.stuff.createTextField(“theTextBox”+i,1+i,0,20*i,200,20);
_root.stuff[“theTextBox”+i].background=false;
_root.stuff[“theTextBox”+i].border=true;
_root.stuff[“theTextBox”+i].backgroundColor=0xFFFFFF;//white
_root.stuff[“theTextBox”+i].borderColor=0x000000;//black
_root.stuff[“theTextBox”+i].multiline=true;
_root.stuff[“theTextBox”+i].wordWrap=true;
_root.stuff[“theTextBox”+i].variable=“watcher”+i;
//create some formatting for our text box
myTextFormat = new TextFormat();
myTextFormat.font = “Arial”;
myTextFormat.size = 12;
myTextFormat.color=0x000000;//black
//format our text box
_root.stuff[“theTextBox”+i].setNewTextFormat(myTextFormat);
}

That works. It creates 10 boxes on the page and in the example I’ve used here, the top three boxes would each display “Bob”, “Blah” and “Hohoho” respectfully.

However, I want the script to be a little more clever than this. As it stands right now, I effectively have 7 boxes needlessly being displayed on the screen. So what I want is for the contents of “count” to determine how many times the FOR loop passes. However, as hard as I try I cannot get the AS to read the variable “count” and use it in the code.

Essentialy, I want the script to say “ok, that PHP file is telling me there are only 3 members to display so I will only create three dynamic textfields” and so it then creates 3 dynamic text fields and places the name from each member into those fields and then stops.