I have a Flash movie I am designing which is a game powered by a PHP backend (BTW this question has nothing to do with PHP/loadVariables/etc, I have that all figured out). The main timeline is separated into several "states" which have descriptive labels. Moving from state to state in the game is done by simply jumping from label to label on the main timeline via functions which tell it where to go based on what info came from the PHP script. There is no actual animation on the main timeline.
All of the actual graphics / animations, etc are separated into movie clips - specifically one for each major state as well as a few others (like the interface which serves as a background).
To make things attractive and more interesting, most states have sort of a fade in and fade out stage (and even some more in the middle). This is where several movie clips within the main state movie clips do animations to look like things are "loading" or "unloading". Example: if I enter a particular state I may tell the interface MC (_root.main_interface) to do an unroll animation just before I put the graphics on top of it. Then maybe at the end of that state when the user clicks a button, a little animation is done (like the interface rolling back up?) just before loadVariables is called and the state changes from that button press.
Here is the problem - it is getting complicated to synchronize all of this. I can't figure out how exactly to tell the parent MC's when the child MC's are done with their little animations and it's time to move to another state. Rather than doing a cheesy method of trying to synchronize all of the animations in one MC with tons of blank frames (which would be a nightmare), my only idea is to have the movie clips send some kind of variable back to the parent movie clip saying something like "i'm done with the animation".. kind of thing... But it gets ugly if I have several different animations going at once.. which one would tell the parent MC it's ok to move on? I mean if a button press does something like this:
_root.send_server_response("hit this button");
As you can see I need all of those animations to be finished Before I send the server response which will jump the main timeline to a completely different part.
So I need a way for those 3 MC's I said to gotoAndPlay to somehow call back and say they're done before I go about contacting the server...
How do experienced designers handle this sort of thing?
Thanks for any help.
Why don't you do as you said? Send the parent a signal when they are done? and use these vars as conditional for _root to move on.
example, on first frame of these clips set a var: done1= false. on last frame same var but: done1=true, same goes with other 2 clips: done2=false / done2=true etc.
Then in a dummy clip:
I used your "goto" there without knowing what you want and you'll need to adjust the pathes and instances names of your own clips... but anyway you got the idea.
If there is a button action involved , that button can set another var into your conditional..
Hope this helps