These are pretty generic scripts, though you would probably want to tweak them a bit to suit your style. The take away is that a wee bit of JSFL upfront can save you hours of grief in the long run.

Download here

The first two are for animation - convertFrames.jsfl and stopFrames.jsfl.

We animate using Sandy's 'Character Pak' methodology, mostly because it lets us plow through hours of it and still find time to drink. It is flexible during the animatic stage, but still easy to work with while nailing down finals and lip sync. The basic idea is there are character 'rest positions', and then Sandy creates animations to and from those. Swap symbols is your friend when stringing these together on the final timeline. Obviously animations are all made out of symbols, so at any time you can break them apart to do some special move. Once broken apart, the heads will talk if you just let them play. Frame 1 is always a closed mouth, and the rest are in a fairly standard order that makes speaking look pretty good (most of the time). Also there is of course a naming convention, mostly common sense where characters sort together in the library, similar motions are named similarly, the head symbols include the word 'head' in them, etc.

So the idea is you first lay out the scenes without animation, just positioning characters and background. Then you do a pass where you make most of the movement, based on canned animation. Once everyone is happy, you go to stage three where you add the final tweaks, and get everyone talking at the right time. This is where the scripts come in. Normally you have to break apart each frame where they start talking, make the head 'play', and then add a frame where they stop to stop it. Then you go in and tweak where it looks bad. Also if they are doing an animated move you have to make sure to break apart the whole sequence at once, or they won't finish the move. Yes, lots of clicking.

The first of these scripts will take a selection of frames and break apart all the ones that haven't been broken apart already, tell the head to move from frame to frame (talk) based on the value of the first frame. The second one takes a selection, breaking apart if needed, and stops them from talking. The idea is you can make 30 frames talk, then 5 in the middle shut up, and then change your mind if need be (they are undoable as well). I hooked this up to two unused side buttons on my mouse, and man it has been useful. I feel like a track star when I animate I tell you : ). If it sounds super fancy and complex, it isn't, take a look. They are both under 50 lines, and really just hacked far enough to work. That is the beauty of JSFL - it doesn't have to be fine art. It's like code gen, as long as it gen's good code, what do you care really?

UI Layout - LayoutGen.jsfl

The third script is much more for the way I program, I would expect you would find writing your own more useful, but having a look first can't hurt either. The problem it solves is this: I like to be able to place UI elements on the screen visually, but then only add them from code using attachMovie. So you end up constantly tweaking the xywh, the layers, the names, match the lib name etc. as your program/design evolves. This is prone to error, and kind of monkey work anyway. So this script combs through the asset FLA file, finds all symbols on the stage, then creates a data file with the names, class names, xywh, and layer of these. Every time I make a tweak I can just do it visually, and run the script off a hot key. It save the data file right into the actionscript files I'm working on (as its own .AS file), so it is pretty seamless. I guess I could go whole hog one day and make it a somewhat complete visual designer, but to be honest after placement and layering visual designers are mostly annoying anyway. My C# workflow tends to be design it visually, get the numbers from a regex or something, and then abandon the visual designer all together. I bet I'm not alone either : ).

The code it generates looks like:

import utils.*;
class utils.LibraryData
{
    // NOTE: Generated Data - do not modify here as your changes will get overwritten!

        public static var gridBarH:LibraryItem = new LibraryItem("gridBarH", 0, 0, 47.8, 34, 899);
        public static var scr_healthOfficeHall:LibraryItem = new LibraryItem("scr_healthOfficeHall", 0, 0, 1245.5, 917.15, 994);
        public static var scr_cafeteriaHall:LibraryItem = new LibraryItem("scr_cafeteriaHall", 0, 0, 792.9, 429.35, 995);
        public static var scr_classroomHall:LibraryItem = new LibraryItem("scr_classroomHall", 0, 0, 807.2, 503.4, 996);

The important thing is it will compile without any intervention on my part, which means it is all very project specific -- but hey it is trivial to modify for the next project so whatever. Of course there is a base UI class that knows automatically what to do with all that stuff, and a class that turns them all into objects with named fields etc, just to play nice with your IDE of choice.

Oh, and unless you want to go insane, put a link to your JSFL folder in your start bar. I think the biggest block to using JSFL is that it is such an absolute fucking pain in the ass to drill down to C:\Documents and Settings\Robin\Local Settings\Application Data\Macromedia\Flash 8\en\Configuration every time you have an idea for a quick little script. Oh and you can't assign custom hotkeys to specific scripts (its based on order, how lame is that?), so careful they don't wander as you add more (you can use names like "aaa_firstScript.jsfl" if you really need). Hitting the wrong script at the wrong time isn't something we should have to deal with. Other than those two **in desperate need of fixing** things, JSFL completely rocks...

Click here to download, feel free to use any way you see fit, of course. Its probably most useful to just have a quick look, maybe even grab some functions, but mostly to see how easy it is to use JSFL on your own trivial monkey work. In a weird way, a crappy JSFL script is more useful that a fancy magic one. Code gen is all about productivity, and the key there is not being too precious, while keeping things easy to modify.

posted on Wednesday, June 27, 2007 1:11 AM
Feedback
No comments posted yet.

Blog Stats

  • Posts - 121
  • Stories - 1
  • Comments - 1441
  • Trackbacks - 47

.Net Blogs

01101 Blogs

Flash Blogs

Graphics

People