JSUI Outlet Function
Hi,
I'm having some issues with the outlet function, i.e, not able to get anything from it
I've tried -
function onclick(x,y) {
post([x,y])
outlet(0, 1);
}
But get error -
Javascript TypeError: outlet is not a function, line 24.
Have also tried variations using bang but having the same issues. outlets is set at the top of the page
post() works fine
Any suggestions please?
Cheers
outlets = 2;
function onclick(x,y) {
outlet(0, x);
outlet(1, y);
}
"outlet is not a function" would happen if you accidentally redefined outlet = <anything> somewhere in your file. For instance setting outlet=3 instead of outlets=3.
To help debug, you can try something like:
post( outlet, "\n" )
post( typeof outlet, "\n")
post( outlet.constructor.name, "\n" )
Thanks for the suggestions, after trying both, I'm getting -
Javascript TypeError: outlet is null, line 19
jsui: error calling function onclick [mym.js]
If I try type of it posts object.
Should I be using the task constructor for the outlet function
This is the initial code, after which I call paint a draw an interface.
outlets = 3;
inlets = 1;
var tsk = new Task();
mgraphics.init();
mgraphics.relative_coords = 1;
mgraphics.autofill = 0;
var p = 0;
var clickCorods = [];
function bang() {
p += 1;
refresh();
}
function onclick(x, y, button) {
// arguments.callee.task.object.outlet(1, "bang");
post(outlet.constructor.name, "/n");
}
// post(outlet);
Cheers
Task should have nothing to do with this. If you're onclick() is being called, outlet() ought to be a valid function since they normally have the same 'this' context automatically.
Forget about the "outlet.constructor.name" debug suggestion. Nothing you've shown looks like an obvious problem. Perhaps show your whole file and console output.
It works on my machine. You may just need to delete the jsui object and re-instantiate it or restart Max. I feel like I've run into a similar issue before...
fwiw I just modified your onclick() to be:
function onclick(x, y, button) {
// arguments.callee.task.object.outlet(1, "bang");
post(outlet.constructor.name, x, y, "\n");
outlet(0, x, y)
}
And got "Function 153 20" printed, plus the expected x and y out the outlet.
Yeah, that fixed it.
Cheers