I’ve created a little TextMate command that automatically creates event handler functions based on the current line of code. If you have a line like…
this.addEventListener(MouseEvent.CLICK, onClick);
… and you hit Command-E, it will copy the event handler code to the clipboard. Look for a demonstration of this in an upcoming video tutorial. I wrote the command using Ruby and you can copy it right out of the Flash screenshot below.
Enjoy it!
Lee








Cant say I have done much with TextMate for Actionscript but I imagine it would be very good.
Thanks for this. I’m always looking for new ways to use TextMate with ActionScript, and this is awesome.
A couple of thoughts, however. If you want to use weak reference with the listener, this won’t work as is. For example,
addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);
Here’s how I changed it to accommodate the last three parameters (the last being the key). Right below second ind definition, instead of second ind2 definition, substitute:
if line.index(“,”, ind)
ind2 = line.index(“,”, ind)
else
ind2 = line.index(“)”)
end
Also, I can’t seem to get the tab (\t) in the output to work if my method is already tabbed out (one or more tabs). The tab (\t) is ignored. Any thoughts on this would be appreciated.
Thanks again!
Boy, I really hate to be a Nagging Neddy, but Command-E is already bound to “Use Selection for Find,” an extremely useful command that lets you bypass the Find dialog altogether (use in conjunction with Command-G for Find Next, Command-Shift-G for Find Previous, Command-Shift-E for Use Selection for Replace, and Command-Option-F for Replace & Find — All of these and more are found under the Edit menu’s Find submenu).
Verily I say unto thee, the hardest part about writing your own TextMate snippets and commands is finding an available key-binding!
Tangential bonus TextMate search tip: Control-S offers a kind of find-as-you-type search mode…press Control-S, start typing, and hit Control-S to find the next match. Handy for quick searches, but not for replacing.
Might I recommend this book?
Hi Lee!
Since i love to have an auto complete code editor, and i hate to have to make a new project each time i want Flex to do some code hint, i am trying to use Texmate.
My doubt is about the damn shortcuts. Since i am new to mac, what is that little clock icon in the shorcuts panel?
Thanks!
Hi Lee
If you are interested in Actionscript code generation you have to check out Eclipse Monkey! it allows to generate scripts directly inside FlexBuilder. I have already created scripts for generate getters, setters, handles functions, consts.
Here is info on my blog
http://panellabs.net/2008/06/01/generate-actionscript-3-code-with-eclipse-monkey-flex-builder/
Lee,
The swf/screenshot is no longer showing up.
I had to view source, find the path, load the swf using an absolute path…not sure what the error might be … trusty Firebug not showing any errors and Activity in Safari show a few files not found but nothing major.
If I had to guess I’d say it was the SWFObject.
/s
Thanks Stephen! Should be working now.
Hi,
for some reason, it shows “interpreter failed:Exec Format Error”
Do you know what could be the reason?
thank you!