Thursday, July 22, 2010

ADDED_TO_STAGE doesn't always fire

Flash development geekery ahead. This is mainly so I can remember the solution to this problem in the future, but maybe this will help someone else, too...

I was struggling with a problem in Actionscript 3 for two hours trying to figure out why some ADDED_TO_STAGE events weren't firing on some MovieClips I had added to some MovieClip symbols I was instantiating.

I had four identical symbols, all the same class inherited from MovieClip, added to another MovieClip symbol in the library. Each would register for an ADDED_TO_STAGE event in itself in the constructor, but when the parent MovieClip was instantiated and added to the stage, only the first of the four MovieClip would actually fire.

The solution? Instead of registering for the ADDED_TO_STAGE event in themselves, I registered in "this.parent", i.e., I would watch for when the parent MovieClip gets added instead of the MovieClip itself. It works, but doesn't seem right. What if I need to make the parent MovieClip a sub-clip of another MovieClip? Will it break again? And how do I remove the listener if the parent changes?

I like the concept of Actionscript 3, but in practice, I'm finding lots of gotchas that make development seem harder than it should be.

Wednesday, July 07, 2010

Treadsylvania is live!

Finally, the ATV safety game we created for National 4-H is live and available for the general public to play. It's called Treadsylvania, and features some fun monster-fighting action! Check it out.