0

In an Animate project, I can see the use count of each item in the library. I open the library with Ctrl + L and I can see that some items are used 1 time, 19 times, or 0 times.

I want to use CS5 JavaScript to get the use count for each item.

There seems to be no way to just do this:

let count = fl.getDocumentDom().library.items[1].getData('useCount');

Or

let count = fl.getDocumentDom().library.items[1].useCount

I have attempted to make the item the selection of the document and then get how many items are selected, as in the code below, but an error shows up saying that the first argument in line 6 is invalid.

var doc = fl.getDocumentDOM();
var library = doc.library;
var item = library.items[1];
library.selectItem(item.name);
doc.selectNone();
doc.selection = [item]; // Error: selection: Argument number 1 is invalid.
fl.trace(doc.selection.length);

I have searched around on the internet and haven't yet found an answer to this exact question.

How do I do this?

HighHopes
  • 2,014
  • 3
  • 23
  • 33
  • 1
    It seems that **document.selection** represents things selected on stage/timelime: Page 157: https://help.adobe.com/archive/en_US/flash/cs5/flash_cs5_extending.pdf The **Library** is a different form of selection (p.370). Literally, you cannot take a **Library** item and say *I select thee in the document*. – Organis Jan 17 '20 at 05:53
  • you just have to add a global count variable inside each symbol, something like this, so every time they use the symbol, it will add 1 to the count. This is something you have to do it yourself after Animate create the js file for you. (lib.mySymbol = function(mode,startPosition,loop) { window.mySymbolCount ++; – DT DT Jan 26 '20 at 01:41

0 Answers0