public boolean mouseDown(Event e, int x, int y) { if (suspended) { animate.resume(); suspended = false; } else { animate.suspend(); suspended = true; } return true; }
// start the applet public void start() { // always start with 1st image gContext.drawImage((Image) images.elementAt(0), 0, 0, this); // create a new animation thread when user visits page if (animate == null) { animate = new Thread(new Animator2Run(this, images, imageTracker, gContext)); animate.start(); } }
// terminate animation thread when user leaves page public void stop() { if (animate != null) { animate.stop(); animate = null; } }