FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   cleaning up
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: cleaning up  (Read 231 times)
Vair


cleaning up
« on: Nov 21st, 2004, 3:15am »

Is there a method that gets called when the applet's window closes? Something analagous to Lingo's
 
on stopMovie
 
I'm playing around with midi files and want to be able to stop the sequencer when the sketch is stopped rather than allow it to continue playing until the sequencer runs out of data.
 
cello

marcello3d WWW
Re: cleaning up
« Reply #1 on: Nov 21st, 2004, 6:06am »

There is public void stop() and public void dispose() from java.applet.Applet...  You could overload those (might be wise to call the super.function in your overloaded version).
 
Marcello
 
Vair


Re: cleaning up
« Reply #2 on: Nov 21st, 2004, 8:55am »

Thanks again Cello,
 
They both work:
 
public void stop(){
  sequencer.stop();
}
 
public void dispose(){
  sequencer.stop();
}
 
I'm afraid that some of your post went over my head - I don't know what super does yet or whether what I've done here is an example of overloading. Is it acceptable to do it this way? Also, which do you think would be better to use - stop or dispose? Is it unsafe to take the belt-and-braces approach?
 
arielm

WWW
Re: cleaning up
« Reply #3 on: Nov 21st, 2004, 9:11am »

the underlying BApplet class is doing its own cleanup stuff inside the stop() method, so this is why you have to "overide" it while using "super", e.g:
 
Code:
public void stop()  // your method
{
  sequencer.stop();
  super.stop();  // BApplet.stop()
}
 

Ariel Malka | www.chronotext.org
Vair


Re: cleaning up
« Reply #4 on: Nov 21st, 2004, 11:19am »

I see. It's to make sure that the stop event moves up the chain.
 
Pages: 1 

« Previous topic | Next topic »