Forums > Javascript

accessing objects attributes in javascript

October 31, 2006 | 7:52 pm

Hi all,

Since it is possible to access all objects/subpatchers in an entire patch structure from javascript, is there a way to access registered attributes of these objects/subpatchers?

As it looks to me now, the only way to do this is to have javascript output a bindto message to a pattr outside the js object and connect the output of pattr back into the js object.

If anyone has some experience with this, I would love to hear about it.

Cheers,
Mattijs


October 31, 2006 | 8:10 pm

On 10/31/06, Mattijs Kneppers wrote:
>
>
> Since it is possible to access all objects/subpatchers in an entire patch
> structure from javascript, is there a way to access registered attributes of
> these objects/subpatchers?

hmm interesting question. I don’t think you can do it just like that, but
I’ve been getting to know the jitter sdk and since you can instantiate any
jitter object in js I’m thinking it’s possible.

-write a jitter object that uses the interface for "findregistered" etc.
-give it an interface through object methods.
-instantiate the jitter object from js

I may be completely wrong here. To me it also sounds an awful lot like the
pattr interface, so maybe a jitterfied pattr object would be a cool
solution? (Jeremy?)

just some thoughts.

cheers, -thijs


October 31, 2006 | 9:14 pm

Quote: thijskoerselman@gmail wrote on Tue, 31 October 2006 21:10
—————————————————-
mm interesting question. I don’t think you can do it just like that, but
> I’ve been getting to know the jitter sdk and since you can instantiate any
> jitter object in js I’m thinking it’s possible.
>
> -write a jitter object that uses the interface for "findregistered" etc.
> -give it an interface through object methods.
> -instantiate the jitter object from js
>

Thanks for your reply. If I get you right, you say first create an object, connect it to the js object, let it retrieve the attribute, delete the object. Interesting thought. And do I understand it correctly if I say that the reason why you want to use a custom jitter object instead of a plain pattr is that the jitter api supports reading not only pattr’s but all attributes of all objects?

> I may be completely wrong here. To me it also sounds an awful lot like the
> pattr interface, so maybe a jitterfied pattr object would be a cool
> solution? (Jeremy?)
>
> just some thoughts.
>
> cheers, -thijs
>
>
>
—————————————————-


October 31, 2006 | 11:59 pm

I’m currently working on an advanced object oriented max solution
which addresses this problem.

heres a quick and dirty solution. write an abstraction wrapper for a
jit.object which saves attributes sent into the left inlet into a colol.


November 1, 2006 | 12:00 pm

On 10/31/06, Mattijs Kneppers wrote:
>
>
> Thanks for your reply. If I get you right, you say first create an object,
> connect it to the js object, let it retrieve the attribute, delete the
> object. Interesting thought. And do I understand it correctly if I say that
> the reason why you want to use a custom jitter object instead of a plain
> pattr is that the jitter api supports reading not only pattr’s but all
> attributes of all objects?
>
>
No, that’s not what I meant…, if I get wat you mean:-).

I’m thinking its possible to change the attribute of any named/ registered
object in max through the C API. You can get a pointer to the object by
calling the findregistered function. Then you can change the attributes. But
you want to do this from javascript. JS can instantiate jitter objects. So I
was thinking:

- create / write / roll your own jitter object, which accepts messages for
binding to other named objects in max, but isn’t really processing matrices.

- instantiate the object in your js code.
- interface through the object.

As I said I might be wrong about this somewhere, but I see no reason why
this can’t work.

cheers, -thijs


November 2, 2006 | 8:49 pm

Hmm, I don’t think I understand your idea of instantiating a jitter object. I’m curious, do you mean there is another way to instantiate a jitter object in JS apart from the patcher.newobject() method?

Thanks,
Mattijs


November 3, 2006 | 11:46 am

On 11/2/06, Mattijs Kneppers wrote:
>
>
> Hmm, I don’t think I understand your idea of instantiating a jitter
> object. I’m curious, do you mean there is another way to instantiate a
> jitter object in JS apart from the patcher.newobject() method?

There is no need for physical objects in Jitter if you’re using JS. Check
out jitter tutorials 45 to 47.

best, -thijs


November 3, 2006 | 2:01 pm

Quote: thijskoerselman@gmail wrote on Fri, 03 November 2006 12:46
—————————————————-
> There is no need for physical objects in Jitter if you’re using JS. Check
> out jitter tutorials 45 to 47.

Ah! Thanks for the pointer (basically rtfm ;). So this is not in the Javascript In Max doc, now I understand what you mean. I think it is a good idea, I will try as soon as I find some time.

Pity that this only seems to work with jitter objects. It would be nice if it was possible to instantiate a pattr object in this way. But well, I put the pattr object permanently outside the js object and use it to retrieve any pattr value I need inside the js. That works fine for now.

Cheers,
Mattijs


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