Last week I wrote a simple script that interacts with my document and exports layers as images.
The script works great, but I thought I'd add a nice UI to it before I release it to the world, so I spent last Saturday making the GUI.
Now, I've built my UI, and I hook it up to my existing code.
If I trace the current "activeDocument" at the beginning of my code, before I instantiate the window, I get what you would expect:
alert("Current Window:"+.app.activeDocument);// Traces - Current Window:[Document myTestDoc.ai]
Now if I try to reference my document from the window click handler, or after I've closed my window I get this:
alert("Current Window:"+.app.activeDocument);// Traces - Current Window:[Document]
alert("Current Window:"+.app.documents[0]);// Also Traces - Current Window:[Document]
The script can still see the document, but suddenly it can't introspect it.
"app.documents" yields the correct number of open documents,
"app.name" yields the correct application "Adobe Illustrator"
but anything like the following will fail.
alert(app.documents[0].layers.length);
Any advice would be massively appreciated.
thanks,
-J