Forum Home
Press F1
 
Thread ID: 108076 2010-03-12 23:26:00 Flash CS4 Actionscript 2, variable problem justinsg (11165) Press F1
Post ID Timestamp Content User
866748 2010-03-12 23:26:00 Hi there,
I am trying to access a variable from outside the function it has been set in:


testVar = "abc";

lv = new LoadVars();
lv.load("data.txt");

lv.onLoad = function()
{
_root.testVar = "hello";
};

trace(testVar);

Theoretically, the trace on the last line should output "hello" but it just says abc still.

What have I done wrong?
This code is in all in the first frame action dialogue
justinsg (11165)
866749 2010-03-13 06:10:00 Gee you must be clever to be using that stuff, maybe you could help me build my time machine. Driftwood (5551)
1