Forums > Javascript

Texture to using javascript

November 11, 2010 | 12:08 am

Hi, I’m trying to assign a texture to 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;

var molti = p.getnamed("moltiplicatore");

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

var texture = new JitterObject("","foo"); = "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 ;)

November 11, 2010 | 12:15 am

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

November 12, 2010 | 12:44 am

WOW Thank you so much!

November 17, 2010 | 12:40 am

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("","fooz"); = i.toString();
textures.file = immagini[i];

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

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

but i get:

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

November 17, 2010 | 2:23 am

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


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

Forums > Javascript