Forums > MaxMSP

Alternating between images with select

April 2, 2008 | 10:01 am

In the patch below, I have one image being displayed when the patch is loaded, but when a bang is sent from the receive object,
a second image takes its place for a couple of milliseconds and then disappears. E.g. the image is white when the patch is loaded and each time a bang is received the picture flashes red and then returns back to white.

However, occasionally if an odd number off bangs are received, the image gets stuck on red and therefore works in the reverse order, flashing white when a bang is received. Is there a way to ensure that the image will only ever flash red without getting stuck?

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 399 177 49 196617 delay 90;
#P button 343 101 15 0;
#P toggle 371 199 15 0;
#P newex 329 28 30 196617 r hit;
#P message 338 355 56 196617 read 2.jpg;
#P message 348 313 56 196617 read 1.jpg;
#P newex 377 280 41 196617 sel 0 1;
#P connect 3 0 5 0;
#P connect 5 0 4 0;
#P connect 5 0 6 0;
#P connect 4 0 0 0;
#P connect 6 0 4 0;
#P fasten 0 1 1 0 397 264 353 264;
#P fasten 0 0 2 0 382 269 343 269;
#P window clipboard copycount 7;


April 2, 2008 | 10:58 am

Maybe by replacing your bang with some triggers ?

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 155 210 21 196617 t 0;
#P newex 155 187 49 196617 delay 90;
#P newex 125 146 21 196617 t 1;
#P toggle 125 237 15 0;
#P newex 125 96 30 196617 r hit;
#P message 125 383 56 196617 read 2.jpg;
#P message 140 343 56 196617 read 1.jpg;
#P newex 125 269 41 196617 sel 0 1;
#P connect 5 0 4 0;
#P connect 5 0 6 0;
#P connect 7 0 4 0;
#P connect 6 0 7 0;
#P connect 3 0 5 0;
#P connect 0 0 2 0;
#P connect 0 1 1 0;
#P connect 4 0 0 0;
#P window clipboard copycount 8;


April 2, 2008 | 11:36 am

the triggers don’t seem to work


April 2, 2008 | 12:20 pm

sorry, my mistake, I forgot that an int in left inlet of delay set delay time and starts delay, so my example triggers a 1 and 1ms after a 0, which is kinda too quick ;)
Try this one:

#P button 251 178 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 215 270 21 196617 t 0;
#P newex 215 239 55 196617 delay 100;
#P newex 185 208 31 196617 t 1 b;
#P toggle 185 297 15 0;
#P newex 185 156 30 196617 r hit;
#P message 185 397 93 196617 brgb 255 255 255;
#P message 200 357 69 196617 brgb 255 0 0;
#P newex 185 329 41 196617 sel 0 1;
#P user panel 206 431 128 128;
#X brgb 255 255 255;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P connect 6 1 7 0;
#P connect 7 0 8 0;
#P connect 9 0 6 0;
#P connect 6 0 5 0;
#P connect 4 0 6 0;
#P connect 2 0 0 0;
#P connect 3 0 0 0;
#P connect 8 0 5 0;
#P connect 5 0 1 0;
#P connect 1 1 2 0;
#P connect 1 0 3 0;
#P window clipboard copycount 10;


April 2, 2008 | 12:26 pm

even simpler without [sel] nor [trigger]:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 87 204 69 196617 brgb 255 0 0;
#P newex 104 146 55 196617 delay 100;
#P message 104 178 93 196617 brgb 255 255 255;
#P button 116 94 15 0;
#P newex 87 122 27 196617 b 2;
#P newex 87 65 30 196617 r hit;
#P user panel 104 242 128 128;
#X brgb 255 255 255;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P connect 1 0 2 0;
#P connect 6 0 0 0;
#P connect 4 0 0 0;
#P connect 2 0 6 0;
#P connect 2 1 5 0;
#P connect 3 0 2 0;
#P connect 5 0 4 0;
#P window clipboard copycount 7;


April 2, 2008 | 1:33 pm

thanks!


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