Forums > Javascript

maxobj.js returns null for a js object?

April 18, 2007 | 1:27 am

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?


April 18, 2007 | 1:49 am

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.


April 18, 2007 | 4:30 am

Ok, we’ll have a look at it.

Thanks for the report.

-A


April 18, 2007 | 5:39 am

Cheers, it would be nice if that worked.

How about this one:

http://www.cycling74.com/forums/index.php?t=msg&th=25628&start=0&rid=3636&S=cfcda99f982a421b2600db2014234214

Regards


April 18, 2007 | 9:53 pm

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


April 19, 2007 | 1:14 pm

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
>
>


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