sending property attributes value to objects from JS ?
hello,
I cannot figure out to send a particular value to, for instance a fpict to change the image file loaded?!
using script messages to Maxobj (representing the ptcher), I can show, hide things etc but I can't find the way to change attributes values.
so I'm using send receive but not the nice JS which is the core of my patch.
What did I miss ??
all the best,
julien
Attributes often have getter and setter methods for checking and setting the attribute. In JS, Maxobj objects have a "message" function used to send a message to the object. You could use this for one of the setter methods. If you are unsure of a setter method, you could check the appropriate object reference, or drag the attribute from the inspector into the patcher window to create a message for setting that attribute.
Here is some sample code showing how to get a reference to a Maxobj in the same patch as the js
object (in this case a number
object) and change the background color to white or black depending on the message sent to js
. In this case the attribute is bgcolor
.
function black() {
var myNumber = this.patcher.getnamed("theNumberBox");
myNumber.message("bgcolor", 0, 0, 0, 1);
}
function white() {
var myNumber = this.patcher.getnamed("theNumberBox");
myNumber.message("bgcolor", 1, 1, 1, 1);
}
hello Roth
didn't answer (that project saturates me!=
thanks a lot.
instructive & interesting