Key Combos in Flashhhhh
Its been nice to have the excuse to learn some more Flash stuff I have neglected over the years. Last week it was database stuff, and this week it was learning to be a better Flash programmer. Not necessarily that much more skilled, but more responsible. Flash is usually a mess after you are done coding it. Script all over the place, almost impossible to debug if you come back to it in a year, or heaven forbid you give it to someone else. Now that I’m starting to do some Flash work professionally, I figured it would be a good thing to get some good habits under my belt.
So, I decided to learn a couple things that would enable me to concentrate my coding to just one place: the timeline… in the actions layer. The main obstacle in that pursuit is button and mouse events. I usually just put them on the movieClips themselves, but that is a bad practice; I needed to learn more about event handlers and such… so I did. And the ‘better’ way is actually better. Yay!
In the process of looking at event handlers, I came across something unexpected and very interesting: An .as script that allows users to use key combinations in Flash. This guy wrote a class that allows you to define key combinations and functions that execute when they are pressed… and the best thing is its easy to implement. The easy part was especially important for me because I had never used external code in Flash, so it was my first… and good news, it was easy and I am no longer afraid of it.
Thats about it really, kinda boring from the outside… but it was really good for me. Oh, and the best thing about the .swf I made was that the only thing in it is two empty frames with actions in them. I know, profesh.
Nice! I’ve been working along the same trajectory (writing .as files, coding in one location). Ha, I still haven’t gotten the nerve to jump into AS3. That’s the summer project…
Here’s a puzzle for you. How can one automatically “select” a flash document embedded in html without clicking? If you notice your app, the key’s do not respond until the user clicks the flash document. This is a big problem for gaming. I haven’t found a viable solution…
Yeah, that seems to be something they added to Flash in the last few versions… I don’t know of a way…