Forums > Javascript

javascript in pasted bpatcher, loadbang method

Jun 28 2012 | 2:29 am

I am using a bpatcher for a widget, and it’s driven by a js object. I need the loadbang() method to execute when i copy and paste the widget, but it doesn’t seem to … loadbang() only happens when I create the bpatcher from scratch. Why is that? Is there an alternate method I should be using?

Jun 29 2012 | 1:50 am

Loadbang() only gets called when the patch initally opens. There might be an easier way to do it, but I’d probably do something like this:

function loadbang(){
   if(!alive){new Global('alive');}

function init(){
  //whatever you had in loadbang()

//this will call the function whenever a new js instance is created in your patch

I haven’t used Globals for a while (I kinda try to stay away from them in m4l due to threading issues), and my syntax might be wrong, but the general idea should work.

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

Forums > Javascript