flash loadVars qu:
- Started
- Last post
- 9 Responses
- jslr
Hey guys n gals,
having a prob with trying to access a variable pulled into actionscript using loadVars...
Using a success/fail function applied to the onLoad event of a loadVars object, I can get the variable into the script - if I trace the variable within the function it calls correctly - so I know I've got THAT bit right at least. But trying to access the variable from outside the function? No joy.
This sucks. Lemons. Big time.
Any help appreciated - been bugging me since last night, and I'd love to be able to get a few hours sleep sometime soon... :)
- finnpimp0
you could copy the var to a global position, for example if the var is called 'chimp' in the txt-file, then just
_root.chimp = loadedObj.chimp
that should make the var accessible from outside the func. if I understood the prob correctly, that is.
- err0
lemme get this straight.
You are trying to loadVariableNum from an outsidesource. Like a txt file or PHP. and you traced it to see if it loads. and it appears like it did. But when you acctually try to use it from within the same swf it won't work. Its as if it never loaded.
If so then read this: http://www.actionscript.org/tuto…
More specifically this part on "swonking"
http://www.actionscript.org/tuto…
- jslr0
see, that's what I'd expect. But it doesn't seem to work. if we call the variable "count", then
_root.count = this.variable
should set "count" to whatever value is in the loaded object's variable. Thing is, it doesn't.
To be a bit more precise, if I trace _root.count in the onLoad function for the object, it returns the expected value. If I trace the same value immediately after/outside the function - diddly squat.
Any ideas?
- jslr0
err - you caught me in mid post there. I'll have a look at the article and get back to you with my findings...
(oh, my sleepless eyes...)
- err0
jslr-
I had those same eyes a few days ago. I feel your pain. Had the same problem. I think.
- jslr0
Hey err,
using loadVars, as opposed to LoadVariables. Built in methods should save the need for swonking, but still no joy with the output of variables.
Desperation is setting in. The pillows are starting to look edible. Where's Superman when you need him?
- err0
Sorry, Jslr
Im not too clear on your problem then. You tried swonking? It still doesn't work?
My advice is to get some sleep. 1 hour and get back at it with a fresh mind. Mmmm pillows
- jslr0
err - got it.
Swonking (wonderful word that) wasn't the issue - it was more about traying to call the variable too soon. If you want the skinny, check:http://www.actionscript.org/foru…
Got some help from Jaybee. Split the script across two frames, and it worked.
Forget actionscript...gimme php.
New skills. Who needs 'em?
G'night all...
- jslr0
Just read over my own post. How easy it is to make no sense whatsoever...
yes, swonking checks that the variable is loaded before you go on to play with it, but the shiny new features of loadVars mean that you can check that data is loaded with a simple function.
I'm still not too sure what the exact problem was - I'm sure it'll make more sense after a good 24 hours of comatose-ness - but we moved the rest of the script that depended on the loaded variable to the following frames. Then we called that frame from the "success" case of an onLoad function.
If none of that makes sense, check the link to the forum and download jaybee's zip.
That is, if y're interested...