Read my threads - you use LoadVars and put value-pairs into an array.
Unfortunately, it was answered in AS 1.0/2.0 forum, not here so perhaps you
didn't find it.
//sqlcache
/* fyi you can always create some valid test data locally by doing something
like this:
var mytest:LoadVars=new LoadVars();
mytest.keyword10="keyword1"
mytest.keyword11="organelle"
mytest.keyword12="photosynthesis"
mytest.keyword13="digestion"
mytest.keyword14=""
mytest.keyword15=""
trace(mytest.toString())
*/
var my_lv:LoadVars = new LoadVars();
my_lv.onLoad = function (success:Boolean):Void {
if (success) {
//assuming _global.keywords is already defined as an array:
//assuming _global.keywords might already have some keywords in it (otherwise
this could be simpler)
//create a temporary array:
var tmpkeywords:Array =[];
// Iterate over properties in my_lv
for (var prop in my_lv) {
if (typeof(my_lv[prop])=="string"){
tmpkeywords.push(my_lv[prop]);
}
}
trace("loaded in this order:"+tmpkeywords); //it is reversed, so:
tmpkeywords.reverse(); //turn it around
trace("reversed:"+tmpkeywords);
//now assuming that the _global.keywords is already an array with some
words... and we want to
//add to the end:
//the following 'function.apply' method lets the 'push' method take the
elements of tempwords as an array an adds them individually
_global.keywords.push.apply(_global.keywords,tmpkeywords);
trace("global keywords now has:"+_global.keywords)
} else {
trace("Unable to load external file.");
}
}
//make _global.keywords an array for testing:
_global.keywords=["hello","world"];
trace("global keywords starts with:"+_global.keywords)
my_lv.load("sqlcache.txt");
//sqlcache.txt
GWD
User is offline
View Profile
Senior Member Posts: 1927
Joined: 06/24/2002
Send Private Message
03/11/2008 05:30:13 AM
Reply | Quote | Top | Bottom
You wouldn't usually want to or need to load the same data in twice.
I checked the link to your swf and I couldn't see it attempting to load any
external data via http activity. So I don't think this code is running in your
full swf (or perhaps it's only after signing in etc?)
Also, LoadVars automatically calls its own decode method by default, so you do
not need to use 'decode' in the onLoad handler.
Here's something which might help. Hopefully the comments etc, explain a
little bit. The function.apply line is probably the one that might be a little
difficult to comprehend. Its only there as a quick way to append the values to
the _global.keywords array (assuming that you want append them).
any insight in going the other way - from flash to php? - see my other post