Groups | Blog | Home
all groups > flash actionscript > february 2004 >

flash actionscript : LoadVars problem



IAMPsycho
2/15/2004 10:23:00 PM
Okay I'm using the LoadVars (object) to open a text file.
Here is my AS
[hr
var input= new LoadVars()
input.onLoad = function (success){ trace("Load Succeeded? " + success)
if (success

for (var p in this

if (p != "onLoad"

trace ("var " + p + " loadeded with value: "+ this[p])




input.load ("loadme.txt")
trace (input.work)
[hr
[U]Here is what I get from my output box:[/U
undefine
Load Succeeded? tru
var class1 loadeded with value: Monday330
var work loadeded with value: Sunday126Monday93033
[hr
I'm trying to access the variable work, but it claims it is undefined. What
is the corret syntax for accessing a variable from the LoadVars(object)? Or is
the variable not loaded yet at the time the action-script tries to call it and
if so, how do I get the actionscript to wait for everything to load. And are
the variables from my text file regarded as global? Or are the varibles scope
limited to just that frame
abeall
2/15/2004 10:45:21 PM
you're right, at thge time of that trace command the var is not laoded yet. It looks like you have the onLoad function there, just put the trace(input.work) within the onLoad function.

IAMPsycho
2/15/2004 11:45:07 PM
abeall
2/16/2004 2:46:27 AM
ye

Flash will not wait for data to be loaded. Therefore the only way to garantee
code is executed after external data is loaded is to use onload one way or
another. You could actually force Flash to stop then paly onLoad, but basically
you need to use onLoad/. Is there a reason you want it outside of the onLoad
AddThis Social Bookmark Button