For the archive. This is the way to do it.

function convert(tFlaPath , tExportPath , tFilename){
        
        
debugMessage += "\n---- Vectorizing file :" + tFilename + " on " + (new Date()).toGMTString() + "\n";
        debugMessage += "SettingstraceBitmap(100, 2, 'normal' , 'normal') \n";

    fl.openDocument(tFlaPath);
        fl.outputPanel.clear();

        
    var doc = fl.getDocumentDOM();
    var library = doc.library;
    var items = library.items.concat();

    i = items.length;

    while (i--) {
        
        var item = items[i];
                var tLayerN;
                
        if (item.itemType == 'movie clip') {
            var timeline = item.timeline;
            len = timeline.frameCount;

                        tLayerN = timeline.layers.length;

                        for(var p=0; p<tLayerN; p++) {
                        
                fl.trace("layers index " + p);

                for(var k=0; k<len; k++) {

                                        library.selectItem(item.name);
                                    library.editItem();
                                
                                        timeline.currentFrame = k;
                                        timeline.setSelectedFrames(k,k,true);

                                        if (doc.selection == "[object Bitmap]"){
                            fl.trace('converted: ' + doc.selection);
                            fl.trace('converted: ' + item.name);
                            doc.traceBitmap(100, 2, 'normal' , 'normal');
                        }
                                }

                doc.exitEditMode();
            }
        }
    }
    filename_new = getNewFileName(tFilename);
    targetPath = tExportPath + "/" + filename_new.toUpperCase1() + ".swf"
        debugMessage += "Exportpath : \n" + targetPath;
        
        
        log(tExportPath);
        
    doc.exportSWF(targetPath, true);
    doc.close(false);
}



Muzak wrote:
This one threw me off a bit :)
You have to move the timeline playhead for traceBitmap to work.
When you enter edit mode, you automatically end up in the first frame, so that's why traceBitmap works for the first frame, and not the others.

So, loop through the number of frames, set "timeline.currentFrame" and then you'll be able to select the elements in that frame and work with them.

This should do the trick:

var doc = fl.getDocumentDOM();
var library = doc.library;
var items = library.items.concat();

var i = items.length;
var item;
var timeline;
var len;
var fr;

while (i--) {
item = items[i];
fl.trace("itemType: " + item.itemType);
if (item.itemType == "movie clip") {
 library.selectItem(item);
 library.editItem();
 timeline = item.timeline;
 len = timeline.frameCount;
 fl.trace("    - frameCount: " + timeline.frameCount);
 for(var j=0; j<len; j++) {
  doc.selectNone();
  // move the playhead !!
  timeline.currentFrame = j;
  // get reference to current frame object
  fr = timeline.layers[0].frames[j];
  // set doc selection
  doc.selection = fr.elements;
  doc.traceBitmap(100, 1, 'pixels', 'normal');
 }
}
}
doc.exitEditMode();

regards,
Muzak

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to