Question

Running a few canvases which work fine in chrome but fail in the latest version of Mozilla. I know this was an issue a while back and I thought the new processing-1.4.1.js was fixed to accommodate for the for loop failure seen here. Does anyone know if they did or if not, why this is happening and how to fix it?

edit:

Test code that will not work:

void setup() {
String names[] = {"Alexis", "Thomas", "Antoine"};
   for(String name : names) {
     alert(name);  // doesn't on Firefox 17+, bug?
   }
}

void draw() {
}
Was it helpful?

Solution

This is a problem with Processing.js and some recent changes in Firefox as discussed here.

You have two options: Solution 1 is to hack Processing.js file as discussed by alexbbrown in the aforementioned link (a harsh and nasty solution), essentially finding the actual Processing.js file, editing it with your favourite text editor and change lines 291-292 from:

if (obj.iterator instanceof
Function) return obj.iterator();

to:

if (obj.iterator instanceof Function && obj.hasNext instanceof Function)
return obj.iterator();

Solution 2 is to change your code and live without the lovely for-each syntax (a softer, compromising solution), replacing the lines:

for (String name : names) {
  alert(name);  // doesn't on Firefox 17+, bug?
}

with the common for syntax:

for (int i = 0; i < names.length; i++) {
  alert(names[i]);
}

whatever you do, may the for be with you...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top