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 › Object using another object
Page Index Toggle Pages: 1
Object using another object? (Read 231 times)
Object using another object?
Feb 28th, 2009, 11:14am
 
Hi Guys,

Maybe this is an easy one, or not. I'm building a Class MyVideo, and have the Capture object declared - but when i go and try to use it, i'm stuck. is it in the right spot- in the constructor? or should it be else where, or something totally different.

(i'm using eclipse, that's what the other stuff is in there for)

Thanks
Jon
Quote:
import processing.video.*;
import processing.core.*;

public class MyVideo {

PApplet p5; // PApplet parent

Capture vid; 



 MyVideo(PApplet _p){


p5 = _p; //parent = p;


vid = new Capture(this,640,480,15);

}


public void disp(PApplet _p){


p5.image(vid,10,10);



}


public void captureEvent(Capture vid){


vid.read();


}

}

Re: Object using another object?
Reply #1 - Feb 28th, 2009, 11:34am
 
You don't tell us what error message you have and where.
The class looks OK although I would make the constructor public.

PS.: avoid tabs in Discourse, they make lines too spaced! Smiley
Re: Object using another object?
Reply #2 - Feb 28th, 2009, 2:03pm
 
Error message is....
The Constructor Capture(MyVideo, int, int, int) is undefined

http://www.flickr.com/photos/jonny_m/3315518517/

http://www.flickr.com/photos/jonny_m/3316344964/

thanks
jon

Re: Object using another object?
Reply #3 - Feb 28th, 2009, 2:15pm
 
I think this works... which means I actually understand what I'm doing Smiley amazing...

So, the constructor needs to know where the PApplet is - and if the constructor is called from inside setup() then use 'this' since you already there, if it is called from somewhere else, in my case the MyVideo class, you need to connect the two together- so, change 'this' to 'p5' (or whatever you named the PApplet parent(?))

http://www.flickr.com/photos/jonny_m/3315531741/


But then, inside my Sketch class, this doesn't work
           
image(vid.disp(),10,10);


Re: Object using another object?
Reply #4 - Feb 28th, 2009, 6:07pm
 
I never used capture (no camera here) but somebody has a similar question: Re: Capture constructor trouble. Maybe this can help.
Page Index Toggle Pages: 1