Answered
LoadVars doesn't work everytime
On both my offline pc in using "test" withing Flash 8 and AS
2.0, and on my unix webhosting server,
I wrote a php script that saves name-value pairs from mysql (Yeah ! Finally - if you read my other posts here!)
&keyword10=keyword1&keyword11=organelle&keyword12=photosynthesis&keyword13=digestion&keyword14=&keyword15=&keyword16=
However, both in the flash enviroment using "test" and in executing the swf after uploading to my server
http://www.4themax.com/education/regents_quest/quiz.swf
sometimes the LoadVars loads and decodes the name-value pairs, and other times doesn't.
Any insight? I haven't uncovered anything in searching this forum nor in googling.
The LoadVars AS 2.0 is (which is in the main timeline):
traces were inserted for debugging during the AS development process.
//sqlcache
var my_lv:LoadVars = new LoadVars();
my_lv.onLoad = function (success:Boolean):Void {
if (success) {
//Convert the variable string to properties
my_lv.decode(my_lv.toString());
//trace(my_lv.toString());
// Iterate over properties in my_lv
i=0;
for (var prop in my_lv) {
//trace(prop+" -> "+my_lv[prop]);
//trace(i+" prop : "+prop);
//trace("my_lv: "+my_lv[prop]);
i++;
}
t = i-2; // used to find total array elements because the decode process populates the elements in reverse order
//trace(t);
} else {
trace("Unable to load external file.");
}
}
my_lv.load("sqlcache.txt");
//sqlcache.txt
//sqlcache repeat
var my_lv2:LoadVars = new LoadVars();
my_lv2.onLoad = function (success:Boolean):Void {
if (success) {
//Convert the variable string to properties
my_lv2.decode(my_lv2.toString());
//trace(my_lv.toString());
// Iterate over properties in my_lv
i=0;
for (var prop in my_lv2) {
//trace(prop+" -> "+my_lv[prop]);
j=t-i;
_global.keywords = my_lv2[prop];
//trace(j+" "+_global.keywords);
//trace(j+"my_lv: "+my_lv2[prop]);
i++;
}
} else {
trace("Unable to load external file.");
}
}
my_lv2.load("sqlcache.txt");
//sqlcache.txt repeat
I wrote a php script that saves name-value pairs from mysql (Yeah ! Finally - if you read my other posts here!)
&keyword10=keyword1&keyword11=organelle&keyword12=photosynthesis&keyword13=digestion&keyword14=&keyword15=&keyword16=
However, both in the flash enviroment using "test" and in executing the swf after uploading to my server
http://www.4themax.com/education/regents_quest/quiz.swf
sometimes the LoadVars loads and decodes the name-value pairs, and other times doesn't.
Any insight? I haven't uncovered anything in searching this forum nor in googling.
The LoadVars AS 2.0 is (which is in the main timeline):
traces were inserted for debugging during the AS development process.
//sqlcache
var my_lv:LoadVars = new LoadVars();
my_lv.onLoad = function (success:Boolean):Void {
if (success) {
//Convert the variable string to properties
my_lv.decode(my_lv.toString());
//trace(my_lv.toString());
// Iterate over properties in my_lv
i=0;
for (var prop in my_lv) {
//trace(prop+" -> "+my_lv[prop]);
//trace(i+" prop : "+prop);
//trace("my_lv: "+my_lv[prop]);
i++;
}
t = i-2; // used to find total array elements because the decode process populates the elements in reverse order
//trace(t);
} else {
trace("Unable to load external file.");
}
}
my_lv.load("sqlcache.txt");
//sqlcache.txt
//sqlcache repeat
var my_lv2:LoadVars = new LoadVars();
my_lv2.onLoad = function (success:Boolean):Void {
if (success) {
//Convert the variable string to properties
my_lv2.decode(my_lv2.toString());
//trace(my_lv.toString());
// Iterate over properties in my_lv
i=0;
for (var prop in my_lv2) {
//trace(prop+" -> "+my_lv[prop]);
j=t-i;
_global.keywords
//trace(j+" "+_global.keywords
//trace(j+"my_lv: "+my_lv2[prop]);
i++;
}
} else {
trace("Unable to load external file.");
}
}
my_lv2.load("sqlcache.txt");
//sqlcache.txt repeat
