fl.runScript(fl.configURI + "Commands/lib/SourcePath.jsfl"); var tmpFilePath = "file:///tmp/docClassCheckerIds.txt"; if (FLfile.exists(tmpFilePath)) { var contents = FLfile.read(tmpFilePath); var lines = contents.split("\n"); var iLen = lines.length; for (var i = 0; i < iLen; i++) { var line = lines[i]; var pieces = line.split("="); var eventType = pieces[0]; var eventId = pieces[1]; fl.removeEventListener(eventType, parseInt(eventId)); } } var changeId = fl.addEventListener("documentChanged", onDocumentOpened); FLfile.write(tmpFilePath, "documentChanged=" + changeId); function onDocumentOpened() { fl.trace("Event happened.") testForDocumentClass(); } function testForDocumentClass() { var doc = fl.getDocumentDOM(); if (!doc) return; if (doc.asVersion < 3) return; var documentClass = doc.docClass; if (documentClass == "") return; var source = new SourcePath(); var classPaths = source.pathsURI; var iLen = classPaths.length; var classPath; var docClassPath = documentClass.replace(/\./g, "/") + ".as"; for (var i = 0; i < iLen; i++) { classPath = classPaths[i]; if (FLfile.exists(classPath + docClassPath)) { // We found a matching file, so no further action is required. return; } } // If we got here, we didn't break the loop on success, so we didn't find a Document Class. alert("Couldn't find a document class called \""+documentClass+"\" for this document."); } testForDocumentClass();