At 9:00 AM +0100 6/12/04, James Newton wrote:
the fact that startMovie occurs after beginSprite can be used to advantage. When you have a number of behaviors that need to talk to work together, you can initialize them in frame one. Then on startMovie, you can create a manager object that asks the sprites "Where are you and what do you do?"
And then you will have structure of sprites and movieScripts that is glued to frame one; Loss of flexibility when you realize you want something extra before that structure, or you just want to take that structure, and use it in another context; Loss of reusability.
It's like OOP with fixed globals, where you become glued to the ceiling - here you just become glued to the left wall.
If you need a one-shot event for initializing a managed cluster of behaviors, I have taken advantage of the fact that the one-shot events in the frameScript happens AFTER one-shot events on the sprites.
(Something Tweed should include in his research.)
From the beginSprite in the frameScript I sendAllSprites #begunSprite, like I have hacked an extra convenient event into Director.*
Of course that's not a self-contained solution for the cluster, but for that you can use a timeoutObject:
On beginSprite of your managerBehavior, you set up a timeoutObject, and catch the prepareFrame event it sends back, and forget the timeoutObject immediately on its callback.
That solution has the small trade-off that you will have a constantly running prepareFrame handler, which you need to flag out somehow. (You can exploit the param with a ref to the timeoutObject)
The solution to that is to use an intermediary callbackScript implementing the prepareFrame handler, but then the self-containing of the cluster deflates a bit again.
Cheers, Jakob.
*
And NO. I don't think beginSprite in the frameScript constitutes a broken mug. ;-)
[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
