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 › Capture constructor trouble
Page Index Toggle Pages: 1
Capture constructor trouble (Read 353 times)
Capture constructor trouble
Feb 12th, 2009, 8:59pm
 
Hello there,

I'm having trouble building a simple constructor for a class to handle all my intended video methods.

The error I'm having is this: "The constructor pixel_video_OOP_rewrite.Video(pixel_video_OOP_rewrite) is undefined"

and the code...
Code:

import processing.video.*;

void setup() {
size(640, 480, JAVA2D);
Video video = new Video(this);
}

void draw() {
}

class Video {

Capture v;

void Video(PApplet p) {
v = new Capture(p, width, height, 15);
}

}


Any pointers as to where I'm going wrong here?

Many thanks.
Re: Capture constructor trouble
Reply #1 - Feb 12th, 2009, 10:40pm
 
Constructors have no return type, not even void.
There you declare the method Video(PApplet), not the constructor.
Note you don't even need to pass PApplet:
Code:
import processing.video.*;

void setup() {
size(640, 480, JAVA2D);
println("Setup: " + this.getClass());
Video video = new Video(this);
}

void draw() {
}

class Video {

Capture v;

Video(PApplet p) {
println("P: " + p.getClass());
println("Video: " + this.getClass());
println("Video's parent: " + this.getClass().getEnclosingClass());
}
}
Re: Capture constructor trouble
Reply #2 - Feb 14th, 2009, 2:21pm
 
Aha! many thanks.
Re: Capture constructor trouble
Reply #3 - Feb 14th, 2009, 8:12pm
 
Aha, I just saw a simpler alternative to get the parent's instance:

<sketch name>.this

Eg. if you name your sketch VideoTest, it will be VideoTest.this.
Page Index Toggle Pages: 1