With ID many of the events are fired multiple times for a given user action (say opening a document). If you look at the target of the event, you should see that the events are being fired with different targets.
If you are using or have access to Extension Builder, there's a sample application called Event Watcher. That extension allows you to register for ID, PS, AI events. The panel shows you what events fire when.
I think the AS was Applescript and not Actionscript...
I figured that as well given the forum.
I mentioned the Extension Builder watcher extension only because it is the only one I know of that'll easily show the when's, where's, and how's of event dispatching.
Thanks Bob. But, then really how are event listeners reliable? If InDesign's AfterOpen fires 2 (or more) times, how can an action be reliable if it should only activate 1 time, or writes a text log, or even displays a dialog to a user too many times?
My goal is to either make a text file or write to a text file when a document is opened. But if this script runs 2x then for every document action I'll get 2 log entries, and that sort of invalidates the data as being reasonably reliable.
Is there something I'm not understanding about event listeners? Is there a way to filter them? A way to suppress secondary firings?
I don't have Extension Builder (nor access to the Enterprise Dev program at my work).
I found I can filter events by their parent to know who's firing it. Sometimes it's the document sometimes it's a window.
Make sure your testing also covers situations where InDesign documents are opened temporarily / under the hood, for example the source documents for style imports (via style panel flyout menu), or when you place a document, export a PDF from a book referencing the document. I'm not sure whether all of them trigger the event, but at least the styles do it!