2

I have been searching the web for about 2 hours now looking for an extension (MXP) or a JSFL script to help me convert 300 + shapes I have on the stage into symbols. The names don't matter, they could be symbol_001, 002, etc. It seems like such a common task that I'm amazed no one has asked on stackoverflow yet, or even on actionscript.org.

I came across this one but it wasn't what I needed... It only did one symbol at a time...: http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=1848523

While this one does what I want but for bitmaps, and only the ones in the library. http://benclinkinbeard.com/2006/07/flash-extension-convert-bitmaps-to-symbols/

Please help!

KorinW
  • 279
  • 4
  • 10
  • I guess people first draw them as symbols then place them to stage, and not vice versa. This is easier and more versatile. I think you should use that first one of your findings, 300+ times. – Vesper Oct 19 '12 at 07:35
  • Well, my symbols in this case are words, its much easier for me to type out the whole paragraph and then slice up the words with a JSFL script I created. – KorinW Oct 20 '12 at 01:44

1 Answers1

3

first thing are those 300+ shapes on the same timeline and frame? secondly are those shapes grouped?

var el = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements;
for(var i = 0; i<el.length; i++)
{
    fl.trace(i+" - " + el[i]);
}

this will enumerate all elements (including shapes) on the timeline of first layer in first frame.

Now not grouped shapes will be treated as single shape, rectangle or oval primitives will be separate.

This is the documentation of Element object and this Shape object doc.

Following is working sample example I used modified convertToGraphics method found here:

var el = fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements;
for(var i = 0; i<el.length; i++)
{
    fl.trace(i+" - " + el[i]+", "+el[i].isGroup);
    convertToGraphics(el[i], "shape"+i);
}

//converts all current elements on the current timeline to movie clips with a effectSymbols move to Effect folder in the library and center registration point
function convertToGraphics(el, name)
{
    try
    {
        var symbolName = name;

        var cur_lib = fl.getDocumentDOM().library;
        fl.getDocumentDOM().selectNone();

        fl.getDocumentDOM().selection = [el];
        while(cur_lib.itemExists(symbolName+i))
            symbolName=symbolName+1;
        var newSym = fl.getDocumentDOM().convertToSymbol("movie clip", symbolName+i, "center");
    }
    catch (e)
    {
        fl.trace("Exception in : convertToGraphics" + e);
    }
}

best regards

p.s. 2 hour of search is just not enough

Lukasz 'Severiaan' Grela
  • 6,078
  • 7
  • 43
  • 79