Texture to jit.gl.multiple using javascript

Nov 11, 2010 at 12:08am

Texture to jit.gl.multiple using javascript

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

Attachments:
  1. photorotowall.zip
#53258
Nov 11, 2010 at 12:15am

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”);

#191369
Nov 12, 2010 at 12:44am

WOW Thank you so much!

#191370
Nov 17, 2010 at 12:40am

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< (immagini.length); 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

#191371
Nov 17, 2010 at 2:23am

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

#191372

You must be logged in to reply to this topic.