can't move fpic with Maxobj.rect, is there another way?

Oct 23, 2007 at 3:45am

can't move fpic with Maxobj.rect, is there another way?

I’ve been using Javascript to move objects successfully, but it doesn’t seem to work on the fpic object. See sample code below for an example of my problem.

Is there another way to move fpic objects through javascript?

Thanks
Dan

Save this as “fpic_move_test.js”:

inlets = 1;
outlets = 1;

//// these functions look the same to me, but moving the fpic doesn’t work.
////
//// is there a way to move an fpic object in javascript?

function move_myPanel(X, Y)
{
/// get my panel object
var myPanel = this.patcher.getnamed(“myPanel”);

/// move the 100×100 Panel
myPanel.rect = [X, Y, X+100, Y+100];
}

function move_myFpic(X, Y)
{
/// get my fpic object
var myFpic = this.patcher.getnamed(“myFpic”);

/// move my Fpic
myFpic.rect = [X, Y, X+100, Y+100];
}

And then run this Max patch:

max v2;
#N vpatcher 178 288 821 782;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 92 178 100 196617 This doesn’t:;
#P message 92 196 114 196617 move_myFpic 300 300;
#P message 43 128 120 196617 move_myPanel 285 200;
#P comment 433 132 117 196617 This is named “myFpic”;
#P user fpic 439 172 102 52 DL_Player_Replace_Button_2.jpg 0 0 0 0. 0 0 0;
#P objectname myFpic;
#P newex 43 275 105 196617 js fpic_move_test.js;
#P user panel 290 163 100 100;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P objectname myPanel;
#P comment 279 136 117 196617 This is named “myPanel”;
#P comment 453 148 100 196617 (load any pic);
#P comment 42 109 100 196617 This works:;
#P connect 7 0 4 0;
#P connect 8 0 4 0;
#P pop;

#34280
Oct 24, 2007 at 2:18am

Any takers on this?

I’ve got a workaround where I send information out one of my js object’s outlets and use “script move” messages to [thispatcher], but it seems so much less elegant since I’m doing everything else in Javascript. Am I missing something obvious?

thanks
/dan

Quote: doctor op wrote on Mon, 22 October 2007 21:45
—————————————————-
> I’ve been using Javascript to move objects successfully, but it doesn’t seem to work on the fpic object. See sample code below for an example of my problem.
>
> Is there another way to move fpic objects through javascript?
>
> Thanks
> Dan
>
> Save this as “fpic_move_test.js”:
>
> inlets = 1;
> outlets = 1;
>
> //// these functions look the same to me, but moving the fpic doesn’t work.
> ////
> //// is there a way to move an fpic object in javascript?
>
> function move_myPanel(X, Y)
> {
> /// get my panel object
> var myPanel = this.patcher.getnamed(“myPanel”);
>
> /// move the 100×100 Panel
> myPanel.rect = [X, Y, X+100, Y+100];
> }
>
> function move_myFpic(X, Y)
> {
> /// get my fpic object
> var myFpic = this.patcher.getnamed(“myFpic”);
>
> /// move my Fpic
> myFpic.rect = [X, Y, X+100, Y+100];
> }
>
> And then run this Max patch:
>
> max v2;
> #N vpatcher 178 288 821 782;
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P comment 92 178 100 196617 This doesn’t:;
> #P message 92 196 114 196617 move_myFpic 300 300;
> #P message 43 128 120 196617 move_myPanel 285 200;
> #P comment 433 132 117 196617 This is named “myFpic”;
> #P user fpic 439 172 102 52 DL_Player_Replace_Button_2.jpg 0 0 0 0. 0 0 0;
> #P objectname myFpic;
> #P newex 43 275 105 196617 js fpic_move_test.js;
> #P user panel 290 163 100 100;
> #X brgb 191 191 191;
> #X frgb 0 0 0;
> #X border 1;
> #X rounded 0;
> #X shadow 0;
> #X done;
> #P objectname myPanel;
> #P comment 279 136 117 196617 This is named “myPanel”;
> #P comment 453 148 100 196617 (load any pic);
> #P comment 42 109 100 196617 This works:;
> #P connect 7 0 4 0;
> #P connect 8 0 4 0;
> #P pop;
>
—————————————————-

#115381
Oct 24, 2007 at 4:40am

On 24 oct. 07, at 04:18, Dan wrote:

> I’ve got a workaround where I send information out one of my js
> object’s outlets and use “script move” messages to [thispatcher],
> but it seems so much less elegant since I’m doing everything else
> in Javascript. Am I missing something obvious?

There’s something wrong, in the meantime, you can send the “script
move” message from JavaScript, which is slightly more elegant.

Cheers,
ej

inlets = 1;
outlets = 1;

//// these functions look the same to me, but moving the fpic doesn’t
work.
////
//// is there a way to move an fpic object in javascript?

function move_myPanel(X, Y)
{
/// get my panel object
var myPanel = this.patcher.getnamed(“myPanel”);

/// move the 100×100 Panel
myPanel.rect = [X, Y, X+100, Y+100];
}

function move_myFpic(X, Y)
{
/// move my Fpic
this.patcher.message(“script”, “move”, “myFpic”, X, Y);
}

#115382
Oct 24, 2007 at 4:58am

thanks very much ej!

/dan

#115383

You must be logged in to reply to this topic.