I am making a game using AS3. I have three classes (Spaceship, UFO, and Scoreboard) which are all children of the class GameEngine.
I want to put eventListeners in Scoreboard and then send dispatchEvents from Spaceship and UFO to update the scoreboard instance.
Since Spaceship and UFO are neither parents or children of Scoreboard, adding a bubbling=true parameter to the dispatchEvent does nothing.
How do I get Scoreboard to listen for *dispatchEvent*s without doing this:
GameEngine.scoreboard.dispatchEvent(new Event("shipWasHit", true));
This seems silly to do it this way. Why would I use a dispatchEvent at all -- why not call the function directly? And what if I want other classes to listen for the same dispatchEvent?
Please advise.