flash data integration:
Hi everyone, I'm having what seems like a timing problem with a loadvars.load(), and I require help. I'm writing a data class that encapsulates a heap of loadvars calls into a nice data layer, but I'm having a slight problem with the timing of it all. it seems that the functions that should use the data once it gets into my flash forms app are executing before loadvars actually finishes loading. I've tried it with onLoad and onData event handlers but to no avail, and the trace of the loadvars source IS the data I'm looking for. as I'm from a .net background, I recognise this as the loadvars call running on a separate process or thread to the rest of the app, so my inclination is to either: a) get the two to run on the same thread or b) sleep the main thread to wait for loadvars to finish or as pure speculation, can I get loadvars to tell the other code when to get a move on? It's not something daft like me getting my functions the wrong way round, I've traced the app almost to death, so unless I've completely lost my mind (altogether likely) loadvars is actually finishing after all the other code. any help would be greatly appreciated.
Hi John, The onLoad function is the answer. In a truly data-driven application, your data layer class should generate an event that says "dataReceived" or something like that when the load completes. Your classes that will use the data should listen for that event and execute when they hear it. If you need an example, reply back and I'll see what I can do....
Hey Phil, Yes! I'd be very interested to see how you do this. I used the onLoad handler for loadvars, yet other code was executing before loadVars finished. I got round the problem I had in a somewhat scrappy fashion, by using a setInterval in the form that uses the data to check whether the data is actually there in the class that does the loadvars bit. Not ideal, but it works!!! But as I said, I'm very open to other/better/different ways to do stuff cheers The Sheriff
Don't see what you're looking for? Try a search.
|