3
votes

I have 1000 pngs imported into Flash CS and "modify->bitmap->trace bitmap" gives me exactly what I want (A vector version of the png), but I don't want to manually click through all pngs, so it there an equivalent actionscript code, that does the same on runtime? (Generate a vector shape from a png)

1
Algorithms exist, but it's better to separate bitmaps before, rather than asking each time a calculation.helloflash

1 Answers

1
votes

This works:

1 - Using JFSL and the trace bitmap command for all the images in one shot

First, put a bitmap on the scene and make : modify->bitmap->trace bitmap. Go to "File" > "New" and select "Flash JavaScript File". Save it and name it "TraceBitmapCommand". Open the History panel: "Window" > "Other Panels" > "History" (or Ctrl+F10). You should see something like this in your most recent actions:

fl.getDocumentDOM().traceBitmap(100, 8, 'normal', 'normal');

Paste this line into your JavaScript File. Then modify the code of your JavaScript File like this :

var doc = fl.getDocumentDOM();
var tl = doc.getTimeline();
var curLayer = tl.currentLayer;
var curFrame = tl.currentFrame;
var frameArray = tl.layers[curLayer].frames
var n = frameArray.length;
tl.setLayerProperty('locked', true, 'others');
for (i = curFrame; i < n; i++) {
    doc.selectAll();
    doc.traceBitmap(100, 8, 'normal', 'normal'); //your traceBitmap function here
    tl.currentFrame = i + 1;
}

2 - Downloading the image sequence on your timeline

Put all your images into a folder (named pic001, pic002, pic003...). Open a new Flash file. Go to "File" > "import" > "import in the scene". Click on the first image in your folder, select "open". A window appears asking you if you want to import all the files: choose "yes". All your images are now aligned one after the other in your timeline.

3 - Using your command "TraceBitmapCommand"

Click now on the first frame of your timeline. Go to "commands" > "run command", and select your JavaScript File : "TraceBitmapCommand".