Jsfl script for checking automation in .fla sources

Today I was needed to check several hundreds of .fla files for existance of specified labels in movies timelines. I created jsfl script. See below. It loads all .fla files one by one, finds specified movie and checks its timeline.

fl.outputPanel.clear();

var dir = ‘file:///d|/Projects/civcity/flash/branches/stable/resources/fla/buildings/’;
var n = 442;

var re = new RegExp(“civcity.buildings.”, “”);

for (var f = 1; f <= n; ++f)
{
    var fileURI = dir + ‘b_’ + f + ‘.fla’;
    if (!fl.fileExists(fileURI))
        continue;
    fl.openDocument(fileURI);
    var items = fl.getDocumentDOM().library.items;
    for (var i=0; i < items.length; i++)
    {
        item = items[i];
        name = item.name;
        if (name.match(re))
        {
            if (item.symbolType == ‘movie clip’)
            {
                var hasPreview = false;
                var hasIdle = false;

                tim = item.timeline;
                for (var l = 0; l < tim.layers.length; ++l)
                {
                    var lay = tim.layers[l];
                    var labels = [];
                    for(var fr=0; fr<lay.frames.length;++fr)
                    {
                        if(lay.frames[fr].labelType == “name”)
                        {
                            if (lay.frames[fr].name == ‘Preview’)
                                hasPreview = true;
                            if (lay.frames[fr].name == ‘Idle’)
                                hasIdle = true;
                        }
                    }
                }

                if ((!hasPreview) || (!hasIdle))
                {
                    fl.trace(f);
                    fl.trace(name);
                }
            }
        }
    }
    fl.documents[0].close();
}

fl.trace(“Done”);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: