JSFL Class Generator

Back in the AS2 days, I created a JSFL script that would trace out the code for a MovieClip class based on items on the timeline. This eventually got ported to AS3, and it had become an essential part of my day-to-day workflow. However, there were some critical shortcomings. One was that it couldn’t identify instances of other custom components in your library. It just typed them as MovieClip. And, most importantly, (due to the limitations of JSFL at the time), it couldn’t actually output a real class file.

I have now updated this script, and my new class generator has much better timeline instance introspection and it actually creates the class files for you. To install, download Bumpslide Component Class Generator JSFL File and put it in your Flash commands folder. This will create a new entry in your Commands menu called “[Bumpslide] Generate Component Classes”.

I’ve put together a quick screencast so you can see this in action. The quicktime download is your best bet.

Download: Quicktime MOV File (960×600, 8.57MB)

What this command does is that it looks through your library and finds all library items that have a custom linkage class name. If the class extends flash.display.MovieClip (or if the base class is blank), it checks to see if a classfile exists, and if not, it creates it for you. When it does this, the script looks at all the items on the timeline and adds relevant properties to your class. If these clips are instances of other components, they will be typed as such, and relevant import statements will automatically be added to your class. If your component is set to extend some other class (for instance, com.bumpslide.ui.Button), no class will be generated. Class files will be written to the correct package location inside the first custom class path defined in your publish settings.

Now, of course, this is most useful to those developers like me who turn off the ‘Automatically declare stage instances’ option in your Flash preferences. I won’t go into a long rant about that here, but when you’re using an advanced code editor like FDT, having references to all of a component’s timeline items clearly listed and meaningfully typed in in your class file is quite important.

This is currently set up to create classes that extend AppComponent which is the name of the application-specific component base class I use in my app template. And, it’s assumed that this class is in the same package as the component classes you are generating. In practice, you’ll often have to change that base class, but this gives you a great starting point. I’m assuming you will customize this code. At minimum, you’ll want to change the author name which is pulled out to a config var near the top of the script. The code near the bottom is where the class template is located.

Hack away, and let me know if you have any suggestions. One issue I’m trying to solve is that I still can’t seem to get JSFL to dig into grouped items. Anyone got any ideas on that?

Tags: , ,

5 Responses to “JSFL Class Generator”

  1. joshk Says:

    still use cs4 as the ide. what is the ideal ide environment from your pov?

  2. John Says:

    Very cool. The link to the AS2 version doesn’t work. I’m actually doing some Flash LIte 3.1 stuff and would like to check that out, if still available.

  3. david Says:

    links to the old jsfl script have been fixed here and in the related post.

  4. jimb Says:

    Great David
    One problem though is that all the classes are generated to the root volume, not the relative class path defined in publish settings

  5. david Says:

    it should grab the first class path in your list. the jsfl is doing some guesswork there. hack it if necessary. works for me :)