Forums > Javascript

javascript patchcord out of range

July 19, 2013 | 8:21 am

I’m working on a project with some javascript and jsui elemets, I want to create them and automatically, when I create them, the code should create a send and a receive object and connect them to the js/jsui object, but, I receive an error of patchcord out of range.
If I open the code of a created item and I save it again it works…

Is a bug or am I doing something wrong?

I’ve attached a sample patch with a really simple javascript code.

I’m under windows7 64 bit and I’m using Max6 64bit. But the error persists also with the 32bit version.


July 21, 2013 | 10:25 am

The problem is that you’re calling your _init method in the global code. And there’s no guarantee that the patcher is ready when the global code is parsed. So you need to defer the creation and connection of the object when the patcher is ready: at loadbang (or using a clock to defer this to later).


Viewing 2 posts - 1 through 2 (of 2 total)