FlashDevelop Code Generation

February 21st, 2008 by Steven Sacks

FlashDevelop Beta 6 was released last Friday and with it came a great new tool for contextual code generation.

It will generate event handlers, getter/setter methods, unknown members, promote local variables to instance variables, and insert interface methods. As you probably can probably guess from my Gaia Flash Framework, I'm a big fan of code generation.

Update! A commenter pointed out that putting braces on the next line is an option in FlashDevelop.  However, the getter code generation puts the getter on a single line.  I've made a slight modification to the code generation template file.  If you dig on the forums you'll find out where the code template file is.

Here is the updated file. Just overwrite your Generator.txt file with this one for cleaner code generation in FlashDevelop. I also recommend changing the keyboard shortcut from CTRL+SHIFT+1, which is awkward, to say the least, to something like ALT+2, which is natural to press with your thumb and middle finger and not natively reserved by anything in FD.

Posted in Actionscript, Tips/Tricks, Workflow

11 Responses

  1. Mike Keesey

    "I used to hate it, but I decided to try it for a month and I discovered why it’s popular"

    Why is it popular? (Still hate it, myself.)

    These additions are great–nice to have some of the code generation functionality that Eclipse offers for Java. But I'm finding a few problems with FlashDevelop's implementation. For example, if I'm create a class that implements an interface which extends other interfaces, but adds nothing new of its own, then FlashDevelop doesn't create any interface methods when I tell it to. It's like it can only see one level up in the interface hierarchy.

    Still, beats the competition, at least for code generation. Just waiting for everyone to catch up to Eclipse….

  2. Steven Sacks

    The only thing I can say is that it's still in beta, and the interface inheritance issue you brought up will likely be resolved should enough people post about it on the forums. The authors are active on the forums.

  3. Carlos Nazareno

    Having the braces one line after helps a lot in debugging because if you scroll up and down, you'll easily see if the braces line up (and thus can detect missing braces easier)

  4. Lee McColl Sylvester

    Just to comment on using a new line before curly braces, one thing I do religiously is to put spaces between braces and parameters and between parameters and their type specifiers, so for a function signature, I might use

    function myFunction( param1 : Type1, param2 : Type2 ) : Type3

    It makes code far easier to read when you have large classes (or small ones for that matter).

    Lee

  5. fd_alias

    hi. in fd3 program settings (F10), you can set the Coding Style Type to BracesAfterLine (under Indenting in main setting panel). Templates use the $(CSLB) token to determine whether or not the programmer wants those line breaks.

  6. Steven Sacks

    Haha. Man, I should learn to RTFM. I've been manually putting my braces on the next line in FD since version 1.

    Thanks!

  7. flashmech

    Hi Steven, could you shed some light on how you change the keyboard shortcut from CTRL+SHIFT+1 to ALT+2? I've searched through the forums but can't find a solution.

    Thanks in advance! :)

  8. Steven Sacks

    F10 for Program Settings

    Select ASCompletion from left column

    Scrolldown to

    Shortcuts
    – Contextual Generator

  9. flashmech

    Thanks! I was absolutely digging in the wrong place! :D

  10. Porl

    How do you use the getter and setter creation ?

  11. Kronoshifter

    use the contextual code generator shortcut on any class member variable at it's declaration.
    i.e. private var foo:String;
    you would use the shortcut on the part that says foo

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

About Steven Sacks

I am a professional Flash developer with over 13 years of programming experience. I have consulted for high-profile agencies and companies in San Francisco, Los Angeles, Atlanta and New York, and developed numerous award-winning websites and rich internet applications for clients including Adobe, Fox Sports, FX Networks, Anheuser-Busch, GE, DirecTV, ESPN, The Weather Channel, Home Depot, and Coca-Cola.

I am the author of the open-source Gaia Framework for Adobe Flash, which dramatically reduces development time and makes developing Flash sites much easier.