jsextensions and outlets
I need some help here. I have a (large) custom object that I want in the jsextensions. There are setters and getters in the object and the getters are supposed to go out an outlet. I came across this example of how to approach the outlet in the jsextensions folder:
function doit(myObject)
{
myObject.outlet(0,"bang");
}
So in my case I got something like this:
function MyObject()
{
this.self;
this.setSelf = function(_self)
{
this.self = _self;
}
this.test = function ()
{
this.self.outlet(0, "output this from my custom object to max…");
}
}
In my js object I create my object like so and try and call the test function:
function bang()
{
var model = new MyObject();
model.setSelf(model);
model.test();
}
Now my hope was that when I call model.test()
, I would get something out my outlet, but all I get are error messages. Is there a way to do this? Eventually I am going to have a large number of these objects stored in an array, so sending the information directly from MyObject to the receiving part in Max is going to be crucial. Are there alternatives? Maybe I could send it to a receive object??
Any clues would be appreciated. I am stuck and can't see the forest for the trees!!
Thanks in advance
for now I am using messnamed("myReceiveObject", "output this from my custom object to max…");
.
This seems to work for now. However, I would still like to know if I can send messages out an outlet from code snippets within the jsextensions folder...
Sorry for any confusion, in the "doit(myobject)" example. the outlet method is only a method of the instantiated js object not any sub objects so from your top level js which uses your jsextension, you need to pass in a reference to your top level js instance.
e.g. extension:
function MyObject(parent)
{
this.parent = parent;
function doit()
{
parent.outlet(0,"foo");
}
}
And in your topmost js file:
function bang()
{
var x = new MyObject(this);
x.doit();
}
Hope this helps.
YES!!! Thanks so much. Haven't tested it extensively, but it works perfectly so far.