import processing.net.*; int numFrames = 3; // The number of frames in the animation int frame = 0; //PImage[] images = new PImage[numFrames]; PImage[] images = new PImage[numFrames]; String [] lines = new String [19]; void setup() { size (640, 480); String lines[] = loadStrings("index.txt"); println("there are " + lines.length + " lines"); for (int i=0; i < lines.length; i++) { println(lines[i]); String numImages = lines[i]; images[i] = loadImage(numImages); //noLoop(); // pixel array of each image } } void draw() { if(mouseY>=height/2){ println (" we are far from the image " + mouseY); } else { println (" we are close to the image " + mouseY); frame = (frame+1)%numFrames; // Use % to cycle through frames image(images[frame], 0, 0); } }