Can anyone share a simple method for obtaining the document index of an active Fireworks document, within the array of open documents? Normally, the current document is accessed by using fw.getDocumentDOM(), but I'd like to obtain the actual array index value (e.g., 0, 1, 2, 3, etc.) to use elsewhere in a script.
I've created a function to obtain this index value, but it's ungainly: It compares entire DOMs that have been converted to source. This requires too much memory or processing and nearly brings the script to a halt. I need something simpler.
var dom = fw.getDocumentDOM();
function documentIndex() {
if (fw.documents.length == 1) {
return 0;
}
else if (fw.documents.length > 1) {
var i = 0;
for (i = 0; i < fw.documents.length; i++) {
if (fw.documents[i].toSource() == dom.toSource()) {
return i;
break;
}
}
}
}
I've considered using a document property like docTitleWithoutExtension, filePathForRevert, or filePathForSave as a basis for comparison between documents, but these are unreliable: They won't work if the documents in question have have not yet been saved.
I figure there must be a simple method, I just don't know what it is.