I have a large array I'm loading from a textfile. So I have, in the first frame of my movie, a stop action, and an empty movie clip with:
onClipEvent(load){ loadVariablesNum("myfile.txt",0); } onClipEvent(data){ _root.nextFrame(); }
This isn't working. I've never used onClipEvent(data), so does anyone know what it is I'm missing? Thanks-
your syntax seems a bit off... loadVarsNum loads variables to a "_level" so there's no way that your movieclip is going to react to that...
here's an example, "holder" is a movieclip on the stage:
holder.loadVariables("hello.txt"); holder.onData=function(){ for (i in this){ trace(i+" = "+this[i]); } }
just as an aside, I think in the inbuilt version of onData(), there's a call to onLoad() like this:
MovieCLip.prototype.onData=function(){ //do stuff this.onLoad(); }
so if you override the onData event and still need to use the onLoad, you can add that line into your function...
how's that??? get you going??
hmm, sure didn't. But I'm at work, and this is a personal project, so I'll have to play more when I get home. Not sure what I'm missing right now.
frustrates
it didn't????
:swear::swear:HOW DARE YOU:swear::swear:

ok, so I was getting ahead of myself... my previous example follows "flash MX" style coding...
here's how you'd put that same code on a movieclip...
onClipEvent(load){
this.loadVariables("hello.txt");
}
onClipEvent(data){ for (i in this){ trace(i+" = "+this[i]); } }
if you're not comfortable with "for in" loops, it just loops through all the properties of an object, so in this case it would loop through all the name value pairs you've just loaded.
is that any better ????

Yes! I think I get it now, thanks.
One more question, though. The textfile has one variable, called "stuff", which has a huge amount of numbers (about 2000) all separated by commas.
So after I load the variable I change that to an array using
stuff=stuff.split(",");
which works fine. But, is this something that I should have built into the preloader as well? Or would that not take much time for Flash to parse it all out, once the original variable is loaded?
As for the Flash MX style coding, I assume I just put that on the main timeline in Flash MX, and it would target the proper movie clip?
yeah, splitting a string like that can take a while... one way around it would be to seperate your preloader into two...
first it would display the bytes or percentages being loaded, then it might say : "parsing data" or something... the thing is, the split takes place over one frame, meaning you can't actually have any animation going on during the split.
so, you need to tell your preloader to say "parsing" one frame before the actual parse, then, move on the frame after the parse...
(hope that makes sense)
if you really went out on a limb, you could divide the "splitting" over frames by chopping it up into smaller chunks with code... but that seems like overkill 
as far as the MX code goes, yeah... right on, the idea is that you can have all your code in one place, rather than having to put snippets on one clip, other snippets somewhere else...

sakri, you rock like Gibraltar, thanks man!


anytime shuteye