Connecting newly-created objects to pre-existing objects

May 30, 2011 at 1:28pm

Connecting newly-created objects to pre-existing objects

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?

#57349
May 30, 2011 at 5:49pm

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.

#205464
May 30, 2011 at 5:49pm

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.

#205547
May 30, 2011 at 7:35pm

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

#205466
May 30, 2011 at 7:35pm

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

#205548

You must be logged in to reply to this topic.