show/hide named object

Feb 1, 2006 at 12:27pm

show/hide named object

This seems so simple, but my simple brain doesn’t want to grasp how to deal w/ maxobj properties. I just want to show or hide specific objects using javascript. I would have expected to do something like
this.patcher.objectname.hidden = 1
but that is too obvious, and wants to invoke a method, of course.

So how would I do this incredibly basic thing?

thanks,

Peter.

#24213
Feb 1, 2006 at 4:08pm

JavascriptinMax.pdf p. 28. The hidden propert of a max object.

wes

#69671
Feb 1, 2006 at 4:38pm

i was there…

and my mail should have stated i also tried

this.patcher.objectname.hidden = 1

and that “objectname” is of course the “scripting name”.
and variations on that. I’m totally lame w/ javascript. I’ve managed
to get some things done with it, quite happily, but i don’t use it
enough for a “second nature.”

so basically, i don’t quite get it….

p.

#69672
Feb 1, 2006 at 4:59pm

You have to do somthing like

myMaxObj = myPatcher.getnamed(objectName);
myMaxObj.hidden = 1;

It’s a property of a JS maxobject. You can’t reference it through
that crazy struct notation you posted.

wes

#69673
Feb 1, 2006 at 5:10pm

> You have to do somthing like
>
> myMaxObj = myPatcher.getnamed(objectName);
> myMaxObj.hidden = 1;
>
> It’s a property of a JS maxobject. You can’t reference it through
> that crazy struct notation you posted.

thanks for clearing that up. I told you I don’t know what I’m doing!!

p.

#69674
Feb 9, 2006 at 6:05pm

and the resulting successful js and its associated helpfile

——-BEGIN JS———-

/*
show and hide controls for input options
takes a message “show ob n h” where
ob is the “base” name of a group of objects, named ob[1], ob[2], and so on
( if you copy/paste a named object in Max, it results in names with the [n] appendage)
n is the number of objects in the group
h is the show/hide integer, where hide=1, show = 0.

by peter nyboer, with the help of the ever-knowledgeable Wes

*/

//variables

var sinecontrols = 4;
var altname = “sine”;

function show(ob,n,h)
{

for (i=1;i< =n;i++) {
altname = ob+”["+i+"]“;
intelement = this.patcher.getnamed(altname);
intelement.hidden = h;
}

}

—————END JS———————-

—————BEGIN HELPFILE————–

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 126 223 106 9109513 example of showhide.js;
#P objectname sine[5];
#P toggle 279 126 15 0;
#P toggle 196 126 15 0;
#P message 196 149 68 9109513 show mic 1 $1;
#P message 279 149 66 9109513 show file 6 $1;
#P toggle 111 126 15 0;
#P message 111 149 70 9109513 show sine 4 $1;
#P newex 111 185 66 9109513 js showhide.js;
#P number 89 67 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname sine[3];
#P comment 126 67 33 9109513 phase;
#P objectname sine[4];
#P number 89 50 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname sine[1];
#P comment 126 50 51 9109513 frequency;
#P objectname sine[2];
#P comment 286 73 25 9109513 loop;
#P objectname file[6];
#P comment 285 56 54 9109513 play/pause;
#P objectname file[4];
#P comment 297 38 21 9109513 file;
#P objectname file[2];
#P toggle 269 73 15 0;
#P objectname file[5];
#P toggle 269 55 15 0;
#P objectname file[3];
#P message 269 36 28 9109513 open;
#P objectname file[1];
#P message 201 76 34 9109513 config;
#P objectname mic[1];
#P connect 13 0 12 0;
#P connect 14 0 11 0;
#P connect 15 0 11 0;
#P connect 12 0 11 0;
#P connect 16 0 15 0;
#P connect 17 0 14 0;
#P window clipboard copycount 19;

—————END HELPFILE————–

#69675
Jan 4, 2013 at 1:53pm

to me this made a little bit more sense:

:)

– Pasted Max Patch, click to expand. –

not sure if the .js posts – if not:

inlets = 1;
outlets = 0;

var box = [8];
var paramName = “paramName”;

function bang() {

for(var i = 0; i

#69676

You must be logged in to reply to this topic.