Wednesday, September 4, 2013

It Works...But I'm Not Happy About It

I've been researching AS3 event handling for days and have not come up with a solution for the pause screen.  I noticed a comment on stackoverflow.com (which, by the way, is a programmer's best friend, I've found) that said to add a mouse click event handler to the stage and output the target and currentTarget of the event to see what is eating the events.  Well, that turned out to put me on the track of a workable solution, despite its hackish nature.

The stage was grabbing all of the click events on the pause screen.  So, I decided to change the addEventListener() call from being attached to the MovieClip that held the button on the pause screen, to the pause screen itself and then finally to the DisplayObjectContainer that the pause screen is getting added to (the stage).  The effect of which is that clicking absolutely anywhere on the pause screen will unpause the game.  Maybe that'll turn out to be a good thing...I still don't like the solution.  If I ever need to add an event listener to a button on a layered screen, I'll have to revisit this problem.  At some point, I should probably read a book or something on AS3 to get some "formal" training.

In any case, progress was made.

No comments:

Post a Comment