I am currently developing an InDesign CS6 Extension using Adobe Flash Builder 4.6. Suddenly, my previously functioning code has started throwing the error null is not an object
. The issue seems to be in a JavaScript injection (last line):
public class Script {
private static var _instance:Script;
[ Embed (source="script.jsx", mimeType="application/octet-stream") ]
private var ScriptClass:Class;
private var jsxInterface:HostObject;
public function Script() {
if (Script._instance) {
throw new Error("only single instance allowed");
}
Script._instance = this;
this.init();
}
public static function getInstance():Script {
return _instance;
}
private function init():void {
Log.log("HostObject.mainExtension: "+HostObject.mainExtension);
for each (var s:String in HostObject.extensions) {
Log.log("Extension: "+s);
}
this.jsxInterface = HostObject.getRoot(HostObject.mainExtension);
this.jsxInterface.eval(new ScriptClass().toString());
}
public function getScript(name:String):Object {
return this.jsxInterface[name];
}
public function exec(name:String, args:Array = null):Object {
return InDesign.app.doScript(
this.jsxInterface[name], ScriptLanguage.javascript, args, UndoModes.AUTO_UNDO); // <-- this is where the error appears
}
I have checked all arguments of InDesign.app.doScript for null values, but everything seems to be correct. This is the function being called inside script.jsx:
function prepareForImageExport(params) {
var pageItem = params[0];
var prefix = params[1];
var bounds = params[2];
var ax = params[3];
var ay = params[4];
// Code continues...
}
I am currently at a loss as to where the error is occurring within the JavaScript code.
Being new to ActionScript, I am struggling to find documentation on debugging JavaScript injections in ActionScript. Additionally, I am unsure about which variables (such as app) are accessible within the JavaScript code and which ones (like console - I can't use console.log) are not.
Any assistance or guidance on this matter would be highly appreciated!