TwelvestoneFlash

onClipEvent(data) for preloader problem


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
shuteye
 
2003-02-03

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-

sakri
 
2003-02-03

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??

shuteye
 
2003-02-03

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

sakri
 
2003-02-03

it didn't????

:swear::swear:HOW DARE YOU:swear::swear:

k

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 ????

k

shuteye
 
2003-02-03

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?

sakri
 
2003-02-04

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 k

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...

k

shuteye
 
2003-02-04

sakri, you rock like Gibraltar, thanks man!

k

sakri
 
2003-02-04

k

anytime shuteye

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

onClipEvent(data) for preloader problem