JSUI Outlet Function

Paul Quirie's icon

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

Source Audio's icon

outlets = 2;

function onclick(x,y) {
outlet(0, x);
outlet(1, y);
}

tyler mazaika's icon

"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" )

Paul Quirie's icon

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

tyler mazaika's icon

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.

Paul Quirie's icon

File attached, still needs some refactoring.
I've tried commenting out all but the onclick function and still have the same issue.
Errors - Javascript TypeError: outlet is null, line 19 jsui: error calling function onclick [mym.js]

Cheers

mym.js
text/javascript 4.88 KB

tyler mazaika's icon

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.

Paul Quirie's icon

Yeah, that fixed it.
Cheers