Forums > Javascript

Set attributes of objects created by Javascript

Jun 23 2010 | 7:01 pm


This is probably a dumb question, but I could not find the answer (may have not been searching properly): Is there a way to set the attributes of an object that I have created using newdefault or newobject? I know I can do something like this "patcher.newdefault(100, 100, "pattr", "@initial", 1);", but I’d rather not have all the attributes in the created object’s rectangle clutter up the patcher. Is there something like an setAttribute method for objects? Is there a comprehensive reference documentation for the possibilities of the [js] object somewhere? Thanks everyone!


Jun 23 2010 | 10:03 pm

from javascript you can:

var p = patcher.newdefault(100, 100, "pattr");

Jun 23 2010 | 10:11 pm

Thanks very much, raja, your suggestion solved my problem. It works like this:

var p = patcher.newdefault(260, 70, "pattr");
p.message("parameter_enable", 1);

Your code snippet, artm, does not work for me, however, but that’s no problem. I prefer the way of writing things like above anyway.

Jun 23 2010 | 10:15 pm

strange. i tried

var p = patcher.newdefault(100, 100, "pattr");

and it worked. had to delete the old pattr though, to avoid confusion :-)

Jun 23 2010 | 10:22 pm

Oh, I just noticed both approaches work, but somehow only the non hidden attributes show the values set by either method in the inspector (e.g. parameter_enable is ticked in the inspector, but initial or initial_enable looks unchanged, but the behaviour is as expected). Strange …

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

Forums > Javascript