We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › ArrayIndexOutOfBoundExeption
Page Index Toggle Pages: 1
ArrayIndexOutOfBoundExeption (Read 420 times)
ArrayIndexOutOfBoundExeption
Jul 7th, 2009, 9:07am
 
i have this code Code:
import processing.video.*;


MovieMaker mm;


PImage img;
PShape s;
float xplus = 0.1;
float yplus = 0.1;

float xx = random(0, 0.05);
float yy = random(0, 10);

void setup(){
mm = new MovieMaker(this, width, height, "randomcores7.mov",
30);

size(720,576);
smooth();
img = loadImage("Image.jpg");


}

void draw(){
mm.addFrame();
fill(255,4);
rect(0,0,width,height);


float x = noise(xx)*width;
float y = noise(yy)*height;
xx += xplus;
yy += yplus;

String[] shapeNames = { "1.svg", "2.svg", "3.svg","4.svg", "5.svg", "6.svg", "7.svg", "8.svg", "9.svg","10.svg", "11.svg"};
PShape[] shapes = new PShape[shapeNames.length];
for (int s = 0; s < shapes.length; s++)

shapes[s] = loadShape(shapeNames[s]);


PShape shapeToDraw = shapes[int(random(shapes.length))];


float r = random(255);
float g = random(255);
float b = random(255);
float prop = random(150);
shapeToDraw.disableStyle();
noStroke();

int x2 =(int) random(width);
int y2 =(int) random(height);
float rot1 = random(5);
color col = img.get(x2,y2);

fill(col);

translate(x,y);
rotate(rot1);
scale(random(0,1));
shape(shapeToDraw,0,0);
ellipse(x2,y2,10,10);

if(frameCount > 400){
mm.finish();
exit();
}


}


and i want to make a little video clip out of it and im getting an error that says " ArrayIndexOutOfBoundExeption" in the mm.addFrame();... does anybody know why? i just made 3 videos with other programs i had done, and it all worked fine, now im having this problem :s
Re: ArrayIndexOutOfBoundExeption
Reply #1 - Jul 7th, 2009, 9:18am
 
i've tried it with other codes that i use an array and it happens the same :s
Re: ArrayIndexOutOfBoundExeption
Reply #2 - Jul 7th, 2009, 12:22pm
 
Not sure why you get this exception, but I remark that you placed the addFrame() before drawing the image. So you get the previous image, not the one being drawn in the current draw(). It might be better to put it at the end of the function.

Also you load and parse SVG files on each frame! Perhaps you should declare the arrays outside and load them in setup().
Re: ArrayIndexOutOfBoundExeption
Reply #3 - Jul 7th, 2009, 12:41pm
 
thank you for your response! i found a way to do it and it was simply by moving the mm = new moviemaker to the end of the setup, and it worked!
Re: ArrayIndexOutOfBoundExeption
Reply #4 - Jul 7th, 2009, 3:05pm
 
Might be something to do with size:

"The size() function must be the first line in setup()."

Sometimes you can get away with it not being first, but sometimes it causes errors; so it's good to get into the habit of always putting it first Wink
Page Index Toggle Pages: 1