CS4 MetaData JSFL Script

It’s been a while since I’ve done much with JSFL, but I’ve been playing with CS4 a lot more than I did with CS3. One thing I love is the ability to set SWF MetaData right on the timeline. I find myself typing in a line of metadata when it would probably be easier to go to the Properties Panel and set the SWF size there. But I’m usually in the Actions Panel with my hands on the keyboard and it just comes quickly.

But I realized I could make it even quicker and wrote the following very simple JSFL script:

[as]_doc = fl.getDocumentDOM();
_tl = _doc.timelines[0];
_layer = _tl.layers[0];
_frame = _layer.frames[0];
headerText =  “[SWF(width=800, height=800, backgroundColor=0xffffff, frameRate=24)]\n”
headerText += “stage.align = StageAlign.TOP_LEFT;\nstage.scaleMode = StageScaleMode.NO_SCALE;\n\n”;

_frame.actionScript = headerText + _frame.actionScript;[/as]

This also sets some common stage properties. Just throw that in your Commands directory in Flash CS4’s Configuration directory. I set up a keyboard shortcut for it: Cmd-Opt-M (for MetaData). Now, with a quick keystroke, my movie is set up the way I want it.

I’m using a very inflexible method of finding the current frame: current document, scene 0, layer 0, frame 0, because that’s where my code always is. You can certainly mess with that to make it more robust if you need it. I started making a SWF Panel that would let you set the dimensions, frame rate and background color with some controls, and then a button to add the code to the frame, then I realized that was pretty stupid, because if you are going to go through the trouble of doing settings and pushing buttons, you might as well just use the Properties Panel. 🙂

This entry was posted in Extensibility, Flash. Bookmark the permalink.

Leave a Reply