2 Replies Latest reply on Aug 24, 2010 12:40 PM by brettpolo

    beforeClose document event




      I'm seeing something very weird, or at least counter-intuitive with the 'beforeClose' event type.


      If I add a simple eventListener with the eventType of 'beforeClose', it seems to be dispatched twice: once before the close, and once after the close.


      #targetengine session
      app.documents[0].eventListeners.add("beforeClose", function()



      If there is only one document open, this will alert the document name twice.  If two or more documents are open, it will alert the document name, and then alert the second document name.


      Has anyone else experienced this?  Anyone know a workaround?  Am I being completely supid?



        • 1. Re: beforeClose document event
          Bob Stucky Adobe Employee

          Check the target of the events. You might find that two events are both fired (because the document is closing), but that the target of each is different.



          • 2. Re: beforeClose document event
            brettpolo Level 1



            Thanks for your response.  Looking into this a bit more, there are, indead, two events that are fired when the document closes.  The first is an Event that targets the LayoutWindow, while the second is a DocumentEvent that targets the Document.  It was a bit counter-intuitive to me that diffrent events could trigger the same eventListener muliple times, but it seems clear now.