Groups | Blog | Home
all groups > flash actionscript > may 2006 >

flash actionscript : loadVariablesNum? I don't get it...


Swhxswt
5/24/2006 9:01:47 PM
I have the following code.

loadVariablesNum("data.txt", 0);

test.text = _global.languageVars.wlecome;

however the textbox with instance name "test" always say's "undefined" why is
this not being defined?

-tim
Travis Newbury
5/25/2006 3:02:54 AM
[quoted text, click to view]

My guess is that _global.languageVars.wlecome is not defined. Maybe
the typo in the word welcome? (you have it as wlecome)
blemmo
5/25/2006 12:37:16 PM
When you use loadVariablesNum(), the variables will end up in the _level you
specified in the parameters, so it's _level0 here, and should be used like this:
test.text = _level0.welcome;

I guess you mixed it up with a LoadVars object, because
_global.languageVars.wlecome looks like that. When you use loadVariables, the
variables are part of the _level or MC where they were loaded into, not part of
an object.

hth,
blemmo
Swhxswt
5/25/2006 1:09:50 PM
oops I had done that.

The following four example don't work.

1)
loadVariablesNum("data.txt", 0);
test.text = _level0.wlecome;

2)
loadVariablesNum("data.txt", 0);
test.text = wlecome;

3)
loadVariablesNum("data.txt", 0);
test.text = _root.wlecome;

4)
loadVariables("data.txt", _root);
test.text = _root.wlecome;
Swhxswt
5/25/2006 2:34:57 PM
With a dynamic text feild in properties when I set Var to 'wlecome' it works fine.

blemmo
5/25/2006 3:11:41 PM
[quoted text, click to view]
fine.

Then I guess the data isn't loaded yet when it's assigned to the textfield.
You might want to wait until all data arrived, then assign it to the text. A
way to do this is using the LoadVars class, or add a variable at the end of the
textfile (e.g. &loaded=1), and check in a loop for it's value. If it's '1', all
data is loaded and you can assign it.
AddThis Social Bookmark Button