1.object literals and 2.initial observations

rsweeten's icon

Hi,

I'm not new to javascript or max, but I am new to JS in max (and to the forums).

1.
Let's say I have a JS maxobject with the following jsobject defined inside it:

var S = {
make: function(v){post(v);}
}

An object literal.
So, from the max patch I can access S with a message box: 'S [arg]' -or- 'S $1', but I can't access the make function defined in S: 'S.make $1'.

The only way I've been able to access S.make is by defining a function after S is defined.

function make(v){
S.make(v);
}

And then of course the message is: 'make $1'
Is this the only way I can get to S.make from the patcher, or am I missing something painfully obvious?

I've also tried:

this.S = {
etc..
}

any takers?

2.
I think part of my problem is I'm getting tripped up on the language in the JavascriptInMax documentation. The word 'Object' gets thrown around willy nilly (well, max or js?), and the identical definition convention of properties AND methods:

someproperty (x, get/set)
somemethod (x, y)

is counter-intuitive. For example it took me forever to figure out that the os property of max is:
max.os // (duh)

and not
max.os(); // to get the property
max.os('string'); //to set the property

Of course this makes perfect sense in the context of javascript (it's array.length, not array.length()), but the documentation often seems to obscure the basics.

Sorry if this has already been talked about somewhere.. but I did see some threads about new javascript documentation in the works and figured it was worth mentioning.

ray