javascript patchcord out of range

Jul 19, 2013 at 8:21am

javascript patchcord out of range

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.

#256478
Jul 21, 2013 at 10:25am

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

#256653

You must be logged in to reply to this topic.