Forums > MaxMSP

message script works.. but not code within .js file?

June 25, 2013 | 5:07 pm

I have a question about java script.

I can send a script message (script newobject led) to [thispatcher] to create an led with no problem. But when I use this.patcher.newobject ("led") inside of a .js file via [js] (with the name of the .js file as its argument)… I get nothing.. only the message "doesn’t understand "led" in the Max window.

I have no problem creating other objects with the same set up.. [button], [message], etc. Why no led? Is there a different name for [led] when referencing it inside of a .js file? I’m confused.


May 13, 2014 | 9:40 am

did you solve this problem??
i had same problems about "led" object.
I am goolgling it and i found only your question.

If you solve this problem, please let me know how to do it.

Thanks!


May 13, 2014 | 11:14 am

I would recommend using newdefault:

led = this.patcher.newdefault(x, y, "led");

where x and y are the xy position of the upper left corner of the object. You can then set the patching_rect of the object by doing something like:

led.patching_rect(100, 100, 60, 60);

-Ben


May 13, 2014 | 11:30 am

Wow, thanks!

I already tried newdefault method, but i confused the order of parameters.
So, I put the name first on it :(
Now, I can make new LED object, but i think still newobject function might have problems…

anyways thank you very much for help me out !!!


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