Rename an element across all frames of a timeline

February 27th, 2009 § Comments Off on Rename an element across all frames of a timeline § permalink

I use a combination of timeline animation and scripting-based movement. All too often, I will create a timeline animation and only later realize that I need to give a MovieClip (or MovieClips) a name so I can refer to it from a script. Of course, this only happens after I’ve already created a zillion keyframes, and going through the entire animation to make sure that each MovieClip has its proper name in each keyframe is a real pain.

I finally got around to creating a simple JSFL script to automate this. It’s nothing special and it doesn’t do much error-checking or anything, but I thought I’d share it regardless in case it helps someone else :)

Copy and paste the following code into a file with the extension “.jsfl” (for example, “Multiframe renamer.jsfl”). Save the file in the appropriate folder, based on your platform:

  • Windows Vista™:
    boot drive\Users\username\Local Settings\Application Data\Adobe\Flash CS3\language\Configuration\Commands\
  • Windows® XP:
    boot drive\Documents and Settings\username\Local Settings\Application Data\Adobe\Flash CS3\language\Configuration\Commands\
  • Mac OS® X:
    Macintosh HD/Users/username/Library/Application Support/Adobe/Flash CS3/language/Configuration/Commands/

and restart Flash.

Then, in your document, select the element you want to be renamed across all frames. The go to the “Commands” menu and choose “Multiframe renamer”. You will be prompted to enter a name for the element (press “Cancel” to abort), and it will go and rename that element across all keyframes in that layer.

No warranty, use at your own risk, etc., but feel free to share and improve on it :)

/* multiframe renamer */
function go()
    if ( ! fl.getDocumentDOM() || fl.getDocumentDOM().selection.length == 0) {
        alert("Please select an element");
        return false;
    var element = fl.getDocumentDOM().selection[0];
    //  use the element's current name as the default
    var name = prompt("New name for elements on this layer?",;
    if (name == null) {
        alert("Cancelled by user");
        return false;
    var timeline = fl.getDocumentDOM().getTimeline();
    //  find the layer from the selection
    var layer = element.layer;
    //  all frames in this layer... rename first element to the name
    for (var i = 0; i < layer.frames.length; i++) {
        if (layer.frames[i].startFrame == i) {
            if (layer.frames[i].elements && layer.frames[i].elements.length > 0) {
                layer.frames[i].elements[0].name = name;
    return true;

Flash CS3 top-left redux

February 11th, 2009 § Comments Off on Flash CS3 top-left redux § permalink

Last May, I complained about the change in the “Info” panel from Flash MX 2004 to Flash CS3. Since I needed the functionality, I whipped up a very simple (and crude) panel to let me see and edit the top-left of an element.

Download the compiled panel and the source code.


As you can see, it’s very primitive. Select the element you want to operate on, and click “Get topLeft” to read the values of its top and left bounds. Click “Set topLeft” to move the selected element.

This comes in handy for changing a MovieClip’s registration point while leaving its visual position intact. Select a MovieClip instance, click “Get topLeft,” then edit the MovieClip and slide its contents around so that the registration point is where you want. Exit MovieClip editing, then click “Set topLeft” (without changing the values in the edit fields). The instance will go back to its original visual position.

JSFL feature request

July 17th, 2008 § 2 comments § permalink

Automating Flash with JSFL is very useful, but I sure wish there was a way to specify “save as Flash 8” in fl.documentSave(). I guess I could run the script in Flash 8 instead… kind of a hassle though.

Tweaking gskinner’s compileProject script

February 21st, 2008 § Comments Off on Tweaking gskinner’s compileProject script § permalink

Recently I had the need to rebuild a whole bunch of Flash movies, more than I wanted to do manually. Before writing my own JSFL script to automate the process, I did a quick Google search and found Grant Skinner’s FLA Batch Compiler script. It’s very flexible and very handy: exactly what I needed.

Grant’s script uses a text file to specify what files need to be built and where the resulting SWFs should be copied. However, the text file uses single tab characters (ASCII 9) to separate the fields, and I like to configure my text editors to insert spaces instead of the tab character.

I made a small modification to Grant’s script to allow any amount of whitespace (spaces or tab characters) in between each field in the schema file.

I changed this (around line 49 in compileProject.jsfl):

    var l = schema.length;
    for (var i=0;i<l ;i++) {
        var row = schema[i].split(String.fromCharCode(9));


    var l = schema.length;
    var regExpDelimiter = new RegExp("[ \t]+");
    for (var i=0;i<l ;i++) {
        var row = schema[i].split(regExpDelimiter);

And that was that!

(I originally tried using the literal RegExp notation [e.g. scheme[i].split(/[ \t]+/)], but it didn’t seem to want to compile that way.)

JSFL in Flash CS3

May 9th, 2007 § 2 comments § permalink

I still don’t have Flash CS3, but I was wondering what was changed in JSFL in the new release. The info is on livedocs. Alas, as far as I can tell, there is no event or anything sent when the selection changes, which would be a great help. Oh well. Maybe in the next version? :P

My first custom Flash panel

January 16th, 2007 § Comments Off on My first custom Flash panel § permalink

I ended up using a different approach to my panel, so I didn’t investigate the problem I was having in my previous post. I’m not running into the issue now, so perhaps it was just something weird with my code.

hierarchical animation panelHere’s what my panel looks like at the moment. The interface is very rough and I’m sure it would make no sense to anyone but myself. It’s a bit of a pain to use, too.

My panel does not monitor the current selection. I tried the test that I linked to in my previous post, and in Flash 8 (at least for me) it causes the IDE to go all wonky: the mouse pointer flickers and changes, and double-clicking on things on the stage doesn’t always work. The symptoms continue even after closing the panel, sometimes! How strange.

Instead, the user has to select the element and then click on the “Get” button. This loads the selection’s information into the panel. “Set” puts the information back into the currently selected element. It’s all rather awkward.

The following two buttons require some explanation. “Memorize Children Pos” takes a snapshot of the positions and orientations of all of the selected element’s “children.” The element’s children are listed in the text area above. Clicking on “Make Children Follow” repositions all of the children of the selected element so that they maintain the same relative positions and orientations as they did when “Memorize” was clicked. Yes, hierarchies of any arbitrary depth are supported, so the children of children (etc) are also moved accordingly.

I am going to continue to use this panel, and perhaps release it, and the source code, at some point. It’s all pretty rough, though, so I am a little hesitant to do so.

JSFL: persistent data not being saved with FLA document?

January 15th, 2007 § Comments Off on JSFL: persistent data not being saved with FLA document? § permalink

Now I’m having trouble with persistent data (set with element.setPersistentData()) being consistently saved when the FLA file is saved. It seems to save correctly with some elements, and not others. It could well be a problem with my code–and for all I know it’s being saved, but it’s not being retrieved properly. I’ll have to try to reduce this down to a reproducible case to see if it really is a Flash bug. Argh.

My first steps with JSFL

January 15th, 2007 § 2 comments § permalink

I’ve started playing with JSFL, which is JavaScript for the FLash IDE. More specifically, I’m creating a custom panel that I hope will make hierarchical animation easier to do on the timeline (at least the way I do it).

Unfortunately, it doesn’t really seem possible to make a panel that updates itself when the selection in the IDE changes (the way the built-in panels do), at least not elegantly or reliably. I suppose it is possible, by having the panel constantly poll the state of the selection, but that seems like a waste of resources, and at least one person out there seems to be having problems with that technique, although I haven’t tried it myself in Flash 8 (looks like the bug still existed in 7.2). I may try it that way anyway…

What I really want are events that my panel can respond to: selection changes, elements being moved, etc.

Another issue I’ve run into: when setting an element’s transformation matrix, the element moves as expected, but the transformation point doesn’t move with it! This leads to some really strange tweening unless you manually reset the transformation point (I just double-click on it with the Free Transform Tool). This will make my panel a real pain to use.

Hmmm… doing some snooping around, it looks like it is possible to change the transformation point using the document.setTransformationPoint() method. However, it only affects the selected elements, which means my code will have to select each element in order to fix it up. Rather messy, but if it works…

Where Am I?

You are currently browsing the JSFL category at bunnyhero dev.