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 & HelpVideo Capture,  Movie Playback,  Vision Libraries › String representing movie image varitable
Page Index Toggle Pages: 1
String representing movie image varitable (Read 305 times)
String representing movie image varitable
Oct 21st, 2008, 2:10pm
 
import processing.video.*;
Movie OneMovie;
Movie TwoMovie;
String c = "OneMovie";

void setup() {
 size(200, 200);
 String c = "OneMovie";
 OneMovie = new Movie(this, "station.mov");
 TwoMovie = new Movie(this, "CheeziPuffs.mov");
 OneMovie.play();
}

void draw() {

 if (key == 'b') {
   OneMovie.stop();
   c = "twoMovie";
   TwoMovie.play();
   image(c, 0, 0);
 }
 image(c, 0, 0);
}

void movieEvent(Movie m) {
 m.read();
}


My problem is it tells me to use void image within the void draw, which as we all know, is just one big synax error waiting to happen, why will it not except a string representing, a name, representing a movie clip. TOo many degree's of separation?

Any help appreciated,
cheers.
Re: String representing movie image varitable
Reply #1 - Oct 21st, 2008, 2:13pm
 
Unfortunately you can't do what you're trying to do. There's no nice way of referring to variables by strings.

What you could do however is something like:

Code:
import processing.video.*;
Movie[] Movies;
//Movie TwoMovie;
//String c = "OneMovie";
int movieNum;

void setup() {
size(200, 200);
//String c = "OneMovie";
Movies=new Movie[2];
Movies[0] = new Movie(this, "station.mov");
Movies[1] = new Movie(this, "CheeziPuffs.mov");
Movies[0].play();
movieNum=0;
}

void draw() {

if (key == 'b') {
Movies[0].stop();
// c = "twoMovie";
movieNum=1;
Movies[1].play();
image(Movies[movieNum], 0, 0);
}
image(Movise[movieNum], 0, 0);
}

void movieEvent(Movie m) {
m.read();
}
Re: String representing movie image varitable
Reply #2 - Oct 24th, 2008, 10:19am
 
Cheers thanks for that
Page Index Toggle Pages: 1