Global Events
May 23rd, 2008After working with AS3 for a bit I finally have come to nice solution to a problem I have alway had with OOP design in flash. Animation gets sticky when you are animating everything with easing classes in nested objects. Alot of times you want one animation to be triggered when something else has happened in another clip. Passing around references to objects in a very large tree can get really sticky. It gets even weirder when you try to move things around. Because of this I usually build some kind off main controller instead of compartmentalizing and extending. The main controller starts getting a little hard to manage on bigger projects. The AS3 event model really help with that. Build one static EventDispatcher, pass it events, and let all the clips that need to listen for events do so without ever having to care what/who sent the event. This is not a crazy concept, just a way of looking at things, that I never did before. In some ways it is probably not the best approach for someone to pick up the files later and start working with them, as they would have to do a project search for the events being broadcasted and listened for, but it is less type errors and less adjusting when a group of objects is added to a new parent.
After doing a lot of this I figured, why not just make an AS2 version for myself for all those banners, and projects that require silly levels of player penetration. I have posted it here. It is nothing fancy, and could perhaps use stuff like bubbling and real events, but for now it seems to be serving my purposes.