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 › this reference within custom class
Page Index Toggle Pages: 1
this reference within custom class (Read 267 times)
this reference within custom class
Apr 16th, 2008, 10:39pm
 
Sorry if this has been answered, I can't seem to find it by searching the forums.

Certain classes (processing.video.Movie in my case) take the current PApplet as the first argument. If I've created a custom class, and I'm loading a movie within that, 'this' refers to my class, not the PApplet.

I tried setting "parent" outside my class and using that:
PApplet parent = this;
but my video isn't loading, and I'm pretty sure this is the issue (it works just fine with the same video in the demo video sketch)

What is the correct way to set the PApplet reference?

thx
Re: this reference within custom class
Reply #1 - Apr 16th, 2008, 11:46pm
 
You need to pass a PApplet object into your class, for it to then pass into MoveiMaker, so for example:

Code:

class myClass
{
PApplet parent;
MovieMaker m;

myClass(PApplet p)
{
parent=p;
m=new MovieMaker(parent,.......);
}


}
Page Index Toggle Pages: 1