I am trying to write a script to convert all the shapes in the flash file to bitmaps, It seems to be working only when the shape is in the first level of timeline, not working when it is nested inside a symbol. The selection length is always 0. document.selection = new Array(element); is not selecting shapes. The code is added below. Please let me know how to convert nested shapes to bitmaps.
(function(){
var document = fl.getDocumentDOM();
var timeline = document.getTimeline();
var updateShapes = function(timeline) {
var layers = timeline.layers;
for (var i=0; i<layers.length; i++) {
var frames = layers[i].frames;
for (var f=0; f < frames.length; f++) {
var elements = frames[f].elements;
for (var e = 0; e < elements.length; e++) {
var item = elements[e].libraryItem;
if (item) {
if (item.timeline) {
updateShapes(item.timeline);
}
}
if (elements[e].elementType == "shape") {
document.selectNone();
document.selection = new Array(elements[e]);
document.convertSelectionToBitmap();
}
}
}
}
};
updateShapes(timeline);
})()