Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
instead of addItem try
doc.getDocumentDOM().library.addItemToDocument({x:0, y:0}); // position where desired.
Copy link to clipboard
Copied
Hi.
Please try this:
Library Bitmaps to Movie Clip instances.jsfl:
var dom = fl.getDocumentDOM();
var timeline = dom.getTimeline();
var layerIndex = timeline.addNewLayer();
var newLayer = timeline.layers[layerIndex];
var lib = dom.library;
var selectedLibItems = lib.getSelectedItems();
var elements;
selectedLibItems.forEach(function(item)
{
dom.addItem({ x: 0, y: 0 }, item);
});
dom.selectNone();
elements = newLayer.frames[0].elements.concat();
elements.forEach(function(element)
{
element.selected = true;
dom.convertToSymbol("movie clip", "", "top left");
dom.selectNone();
});
Regards,
JC
Find more inspiration, events, and resources on the new Adobe Community
Explore Now