Forums > Javascript

Connecting newly-created objects to pre-existing objects

May 30, 2011 | 1:28 pm

Hey
I’ve just started learning to use JavaScript and the [js] object so I can dynamically create and remove objects.
I’ve built a sub-patcher that contains 4 inlets and 2 outlets, and then using the [js] object I will be dynamically creating and removing an object that has 4 inlets and 2 outlets. I then want to connect this newly-created object with the pre-existing inlets and outlets. I know how you go about connecting objects when they’ve all been created using JavaScript, but what script would I use to connect the new object to the pre-existing inlets and outlets?


May 30, 2011 | 5:49 pm

You need to be able to reference the already existing objects that your dynamically created object is connecting to and from, the best way is to give them scripting names and then find them using: this.patcher.getnamed("uniquename") and either assign them to a variable or use them directly in this.patcher.connect(). If that doesn’t make sense then ask and I’ll post a patch that should make things clear.


May 30, 2011 | 5:49 pm

You need to be able to reference the already existing objects that your dynamically created object is connecting to and from, the best way is to give them scripting names and then find them using: this.patcher.getnamed("uniquename") and either assign them to a variable or use them directly in this.patcher.connect(). If that doesn’t make sense then ask and I’ll post a patch that should make things clear.


May 30, 2011 | 7:35 pm

Luke once again you’ve saved the day! Works great Thanks.


May 30, 2011 | 7:35 pm

Luke once again you’ve saved the day! Works great Thanks.


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