Can I add eventListeners to unsaved documents
Hi, what I'm trying to do is add an eventListener to a document so when I place an image in a box it will check the image name against an applied script label. What I have so far works on documents that have been saved but not on documents that haven't been. However if I open a document that has been saved and then click to the document that hasn't been saved the script then starts working. Can anyone explain what is happening here please?
#targetengine 'ImageCheck'
var doc
var el = app.eventListeners.add("afterActivate", getActive);
function getActive(e){
if (e.target.constructor.name == "Document") {
doc = e.target
try {
if (!doc.eventListeners.itemByName("afterImportItem").isValid) {
var afterImportItem = doc.eventListeners.add("afterPlace", checkScriptLabels)
}
} catch(e) {}
}
}