Texture to jit.gl.multiple using javascript

Rajan Craveri's icon

Hi, I'm trying to assign a texture to jit.gl.multiple using javascript but with no result. Everything is good if i write in the object @texture "texturename" but not using javascript.
The javascript code is:

outlets = 2;
var pre=1;
var fois=1;
var iter=1;
f1=0; f2=0; f3=0; f4=0

p = this.patcher;

// OTTIENI GLI OGGETTI NELLA PATCH
var molti = p.getnamed("moltiplicatore");

if (molti == null){
post("couldnt find molti objectn");
}else{
post("ok molti trovato");
}

var texture = new JitterObject("jit.gl.texture","foo");
texture.name = "three";
texture.file = "logo_portogallo.jpg";
molti.texture = "three"; ///// IS IT WRONG ?!?!?

In the attach you can find the patch with image for texture
Thank for help ;)
micron

1352.photorotowall.zip
zip
Joshua Kit Clayton's icon

Unfortunately, for legacy reasons, the Maxobj works differently than JitterObject w/r/t attribute setters. p.getnamed() returns an instance of Maxobj. So you must set the attribute by calling it like a function, or use the message function.

i.e. molti.texture("three"); or molti.message("texture","three");

Rajan Craveri's icon

WOW Thank you so much!

Rajan Craveri's icon

Ok if i use this all is ok
molti.message("texture","one", "two", "three");

but i'm trying to assign texture reading inside a folder so i have to create the message using code,
now i'm using this:
for (var i=0; i

var textures = new JitterObject("jit.gl.texture","fooz");
textures.name = i.toString();
textures.file = immagini[i];

elencotexture = """ + textures.name + """ + "," + elencotexture;
post(elencotexture + "n");// HERE WITHOUT SLASHES

molti.message("texture" , elencotexture); // HERE WITH SLASHES
}

but i get:
"9","8","7","6","5","4","3","2","1","0",

and i would like:
"9" , "8", "7",

like the old manual message
molti.message("texture","one", "two", "three");

i try with a function to stripslashes but no resul
thanks for any suggestions
micron

Brian Gruber's icon

Sounds like you want to use Function.apply. Instead of concatenating all of the names together with +, shove them in an array. Then: molti.message.apply(molti, array_of_arguments)

(btw, you can use backquotes, on the same key with ~ on us keyboards, to get nicely formatted code on the forum).

/brian