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

Reply via email to