MaxObject in javascript and outputing from other objects?

Feb 23, 2006 at 10:13pm

MaxObject in javascript and outputing from other objects?

hello,
i have defined a javascript class function named “jenga” with certain properties and methods.
i have placed this class defining function in my so-called ali-js-tools.js which sits in the ‘jsextensions’ folder;
i can therefore make a new “jenga” object from whatever js code i write;

now, i would like one of the methods of my class “jenga” to output messages from an outlet of js object whose code created the “jenga” object.
in java you can do this by using the “outlet” method of whatever MaxObject. but how do you do this in js?

thanks,
a

#24589
Feb 23, 2006 at 11:33pm

Pass in the jsthis into jenga’s constructor, storing for later use.
For example, something like the following (warning email client
coding). In general this is the strategy to expose any of the stuff
available to the jsthis object inside shared classes.

// in your max object js code:

var myjenga = newjenga(this);

// in your shared jscode:

function jenga(x)
{
this.maxparent = x;

this.foo = function (index, msg)
{
this.maxparent(index,msg);
}
}

-Joshua

#71376
Feb 23, 2006 at 11:40pm

thanks joshua,
i understand passing jsthis to my shared class’s constructor.

the word maxparent doesn’t appear in the JS in max documentation so i having trouble understanding perfectly how it functions.

so in the code you wrote:

// in your shared jscode:

function jenga(x)
{
this.maxparent = x;

this.foo = function (index, msg)
{
this.maxparent(index,msg);
}
}

i’m not sure what the “foo” method of the jenga class does…
is that to outlet messages from the maxparent’s outlets?

once i’ve attached myself to a parent, x, can i do

x.outlet(index.msg)?

like one does with mxj/java?

a

#71377
Feb 23, 2006 at 11:46pm

I beleive that by doing:
this.maxparent = x;

The assignment will create maxparent. It doesn’t need to have existed
before. Joshua just gave the variable a nice name. to call it, you
can do this.maxparent.outlet(0, “message”);

wes

#71378
Feb 23, 2006 at 11:55pm

Precisely. Sorry for the oversight on the method call in my rushed
email client coding.

Thanks, Wes.

-Joshua

#71379

You must be logged in to reply to this topic.