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") {
 timeline = item.timeline;
 len = timeline.frameCount;
 fl.trace("    - frameCount: " + timeline.frameCount);
 for(var j=0; j<len; j++) {
  // 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');


Flashcoders mailing list

Reply via email to