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 › Movie in Custom Class
Page Index Toggle Pages: 1
Movie in Custom Class (Read 1064 times)
Movie in Custom Class
Jan 3rd, 2010, 7:53pm
 
I'm trying to have a Movie as piece of data in a custom Class. The basic class structure is as follows:

class Tile {
 float maxChange = 0.3;
 float currentTime, nextTime;
 Movie clip;
 Tile (PApplet parent, String s_) {  
   clip = new Movie(parent, s_);
 }
}

I'm creating an object like this:
Tile t = new Tile(this, "movie.mov");

However, this throws the error "The file "movie.mov" is missing or inaccessible". I tried to put an absolute path to the file, but that gives me a "
java.lang.NullPointerException".

Any ideas? Thanks.
Re: Movie in Custom Class
Reply #1 - Jan 4th, 2010, 12:00am
 
Are you initializing the Tile class inside of setup()?

Unless the environment has changed (I am using an older version of PDE), some variables, such as the path, are not ready inside the PApplet until main() has been run. (setup() comes after that)

Someone with more knowledge can correct me if I'm mistaken.

Also, for troubleshooting sake, can you get something like this to work?:
http://processing.org/reference/selectInput_.html
Re: Movie in Custom Class
Reply #2 - Jan 4th, 2010, 11:50am
 
Ah. Okay. So that made the object able to be created. Now, though, I get an error "Exception in thread "Animation Thread" java.lang.NullPointerException" with the line t.showClip() highlighted:

Tile t;

void setup()
{
 Tile t = new Tile(this, "movie.mov");
 size(800, 600);
 frameRate(30);
}

void draw()
{
 background(0);
 t.showClip();
}

class Tile {
 float maxChange = 0.3;
 float currentTime, nextTime;
 Movie clip;
 Tile (PApplet parent, String s_) {  
   this.clip = new Movie(parent, s_);
   this.clip.play();
 }
 void showClip() {
   image(this.clip, 0, 0);
 }
}

thanks in advance.
Re: Movie in Custom Class
Reply #3 - Jan 4th, 2010, 9:43pm
 
In setup(), change the line to "t = new Tile(this, "movie.mov");"

By adding "Tile" to the beginning of that line, you are creating another 't' object that can only be referenced inside of setup().

For more info on why it does this, take a look here:
http://processing.org/learning/basics/variablescope.html
Re: Movie in Custom Class
Reply #4 - Jan 5th, 2010, 1:37pm
 
*blush*. Thanks. Just realized this last night and was about to post a follow up for anyone else that overlooked.
Page Index Toggle Pages: 1