JSFL Script Error: convertToSymbol + addItemToStage Failing for Batch Bitmap Conversion
I’m working on automating the process of converting a large sequence of imported bitmap images into individual Movie Clip symbols using JSFL in Adobe Animate (v24.0.9), Mac OS 15.3.2.
My goal is to batch-process each bitmap image from the library by:
Placing it on the stage,
Selecting it,
Converting it into a symbol (Movie Clip),
Assigning a consistent naming structure.
However, I’ve been encountering persistent JSFL errors. Initially, convertToSymbol() failed due to missing selections, and attempts to use lib.addItemToStage() or item.addItemToStage() returned “not a function” errors. I understand these are not valid methods, but I’m unclear on the correct way to programmatically place a library bitmap onto the stage before running convertToSymbol().
Can anyone clarify:
The correct method to add a bitmap (or any library item) to the stage via JSFL?
Whether addItemToDocument() is the appropriate approach?
Any best practices for looping through and converting multiple bitmap assets automatically?
Here’s a snippet from the last JSFL script I attempted. The error is triggered at the line where I try to place the item on the stage:
____
var doc = fl.getDocumentDOM();
var lib = doc.library;
var items = lib.items;
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (item.itemType === "bitmap") {
doc.addItem({left: 0, top: 0}); // Attempted line
doc.selectNone();
doc.selectAll();
doc.convertToSymbol("movie clip", item.name + "_mc", "top left");
}
}
____
I’ve also tried using item.addItemToStage() and lib.addItemToStage(), but both return: “not a function”.
Should I be using addItemToDocument() instead? Or is there another method to insert library items on the stage via script?
Thanks in advance for any insight or working example scripts.
P
