wait until a function has finished running (including transitions and/or timers)?

Hi,

I’ve run into a little problem where I have two functions; loadGame() and startGame() being called one after the other. I’m currently experiencing a race condition where startGame() is executing before loadGame() has had the chance to fully complete. I believe this is happening due to a number of timer.performWithDelay(…) calls occurring inside loadGame(). As a workaround, I am using another timer.performWithDelay(…) call wrapped around the startGame() function and using a time that exceeds the total time of all timers used within the loadGame() function. This then allows the startGame() function to run soon after the loadGame() function has completed, however, this a bit fiddly. I would always need to keep updating the delay wrapped around the call to startGame() if anymore delays were introduced before this call was made - which is undesirable.

So, I was just wondering whether there was another, more official, way to implement this behaviour correctly?

Any help would be appreciated.

Kind Regards,
Rich [import]uid: 125022 topic_id: 36046 reply_id: 336046[/import]