Set attributes of objects created by Javascript

Jun 23, 2010 at 7:01pm

Set attributes of objects created by Javascript

Hi!

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!

Thomas

#51027
Jun 23, 2010 at 10:03pm

from javascript you can:

var p = patcher.newdefault(100, 100, "pattr");
p.initial(2);
p.dirty(1);

#183078
Jun 23, 2010 at 10:11pm

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.

#183079
Jun 23, 2010 at 10:15pm

strange. i tried

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

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

#183080
Jun 23, 2010 at 10:22pm

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 …

#183081

You must be logged in to reply to this topic.