maxobj.js returns null for a js object?

Apr 18, 2007 at 1:27am

maxobj.js returns null for a js object?

As described in the “Javascript in Max” PDF, the js property of a maxobj of class “js” should return a reference to the jsthis inside the object, allowing access to its variables and methods. So given this javascript:

var name = “myname”;
var p = this.patcher;
function bang()
{
box.varname = “jsobject”;
jsobject = p.getnamed(“jsobject”);
post(“class: ” + jsobject.maxclass + “n”);
post(“js: ” + jsobject.js + “n”);
post(“name: ” + jsobject.js.name + “n”);
}

On bang, maxclass is indeed “js”, but jsobject.js is null and has no properties.

Huh? What am I missing here?

#31436
Apr 18, 2007 at 1:49am

More to the point:

function bang()
{
box.varname = “jsobject”;
jsobject = this.patcher.getnamed(“jsobject”);
for(i in jsobject)
{
post(“property: ” + i + ” = ” + jsobject[i] + “n”);
}
}

Looks like a bug to me?
Max 4.6.1, OS X 10.4.3.

#102233
Apr 18, 2007 at 4:30am

Ok, we’ll have a look at it.

Thanks for the report.

-A

#102234
Apr 18, 2007 at 5:39am
#102235
Apr 18, 2007 at 9:53pm

I’ve worked through the examples and tutorials that came with max and now
find I need some more examples.

Here’s what I want to do…

I have written a MouseModifiers patch that watches the mouse button and
transmits the sate of the mouse button and coordinates etc. It transmits
the coordinates when each of the modifiers is engaged.

I’m still developing but here a hypothetical in a LOCKED patcher.

Option click at a point limited to the forward most window (mode 2)
Identify what NAMED object (if any) is located at the click point
Drag to move the object with messages to this thispatcher.

I have been able to do this with patchdescribe-example.pat using
point-in-rect out in max although not yet in the javascript. I need to
know about a point-in-rect function in java script. Ideally, I would like
to get the name of an object and then drag it with something thispatcher
move script.

Here’s another couple (in a LOCKED patch)…

control-click somewhere in a patch and duplicate the object at the
click point.
shift-click somewhere in a patch and copy the object at the
click point including a new name for the object as happens when you
copy in an unlocked patcher

I don’t need you to solve this problem for me. Just pointers to examples.

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

#102236
Apr 19, 2007 at 1:14pm

Gary,

I posted a patch + js called “pattrvoyant” (search string for forum)
a week or so ago which does some of what you’re talking about, and
may help you get started.

jb

Am 18.04.2007 um 17:53 schrieb Gary Lee Nelson:

> I’ve worked through the examples and tutorials that came with max
> and now
> find I need some more examples.
>
> Here’s what I want to do…
>
> I have written a MouseModifiers patch that watches the mouse button
> and
> transmits the sate of the mouse button and coordinates etc. It
> transmits
> the coordinates when each of the modifiers is engaged.
>
> I’m still developing but here a hypothetical in a LOCKED patcher.
>
> Option click at a point limited to the forward most window
> (mode 2)
> Identify what NAMED object (if any) is located at the click point
> Drag to move the object with messages to this thispatcher.
>
> I have been able to do this with patchdescribe-example.pat using
> point-in-rect out in max although not yet in the javascript. I
> need to
> know about a point-in-rect function in java script. Ideally, I
> would like
> to get the name of an object and then drag it with something
> thispatcher
> move script.
>
> Here’s another couple (in a LOCKED patch)…
>
> control-click somewhere in a patch and duplicate the object at the
> click point.
> shift-click somewhere in a patch and copy the object at the
> click point including a new name for the object as happens
> when you
> copy in an unlocked patcher
>
> I don’t need you to solve this problem for me. Just pointers to
> examples.
>
> Cheers
> Gary Lee Nelson
> Oberlin College
> http://www.timara.oberlin.edu/GaryLeeNelson
>
>

#102237

You must be logged in to reply to this topic.