sineadhartley
05-30-2005, 04:41 PM
Hi there
I have just completed tutorial called "loading dynamic data into flash" and now am trying to adapt it for my own use. Just one little small problem that i can't figure out in the for loop. My PHP script works fine coz i tested it in browser and a variable called "$cant" sends back to flash the total number of rows to process which is 3. Right so, below you can see that I assign the PHP variable "cant" to the flash variable "count" (var count = this.cant) and then i trace this to the output panel and i get "count = 3"...lovely..all going well...BUT when i use this variable "count" in the for loop, flash does not enter the loop and none of the load vars object is processed! But when I use the absolute number 3 in the loop i.e. for (var i = 0; i < 3; i++) everything works perfectly!!!! I think am going made because it just makes NOOOOO sense to me. Var count holds the value 3 so why will that variable not work in the for loop????? Can anyone at all help me out??
myData = new LoadVars();
//Fetch data
myData.onLoad = function(succes) {
if (succes) {
var count = this.cant;
trace("count = "+ count);
for (var i = 0; i < count; i++) {
trace("in for loop");
_root["Date_txt"+i].text = this["Date"+i];
_root["Course_txt"+i].text = this["Course"+i];
_root["College_txt"+i].text = this["College"+i];
_root["Grade_txt"+i].text = this["Grade"+i];
_root["Comments_txt"+i].text = this["Comments"+i];
}
} else {
trace("Error loading data");
}
};
stop();
I have just completed tutorial called "loading dynamic data into flash" and now am trying to adapt it for my own use. Just one little small problem that i can't figure out in the for loop. My PHP script works fine coz i tested it in browser and a variable called "$cant" sends back to flash the total number of rows to process which is 3. Right so, below you can see that I assign the PHP variable "cant" to the flash variable "count" (var count = this.cant) and then i trace this to the output panel and i get "count = 3"...lovely..all going well...BUT when i use this variable "count" in the for loop, flash does not enter the loop and none of the load vars object is processed! But when I use the absolute number 3 in the loop i.e. for (var i = 0; i < 3; i++) everything works perfectly!!!! I think am going made because it just makes NOOOOO sense to me. Var count holds the value 3 so why will that variable not work in the for loop????? Can anyone at all help me out??
myData = new LoadVars();
//Fetch data
myData.onLoad = function(succes) {
if (succes) {
var count = this.cant;
trace("count = "+ count);
for (var i = 0; i < count; i++) {
trace("in for loop");
_root["Date_txt"+i].text = this["Date"+i];
_root["Course_txt"+i].text = this["Course"+i];
_root["College_txt"+i].text = this["College"+i];
_root["Grade_txt"+i].text = this["Grade"+i];
_root["Comments_txt"+i].text = this["Comments"+i];
}
} else {
trace("Error loading data");
}
};
stop();