Skip navigation
Currently Being Moderated

Fireworks: How to find document index for scripting?

Jan 22, 2012 10:19 PM

Tags: #javascript #fireworks #scripting #document_index #documentindex #array_position #active_document

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;







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.


More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points