// Applet to do a multi-frame animation with gif's
// This uses an array to cycle through images. 

import java.applet.*;   		// applet classes
import java.awt.*;			// user interface classes
import java.awt.event.*;		// event handling classes
import java.lang.*;			// contains Math class
import java.io.*;

public class animate2 extends Applet {

	Image [] myImages;
	int animate = 0;

	public void paint (Graphics g) {
		int j;

		g.drawImage (myImages[0], 35, 60, this);

		if (animate == 1) {
			for (j = 1; j < 8; j++) {

				try {
		      	 		Thread.sleep (200);
				} catch (InterruptedException e) {}	       

				g.drawImage (myImages[j], 35, 60, this);
			}
			animate = 0;  // reset animation
		}


	}  // paint


	public void init () {
		int i;
		myImages = new Image [8];

		for (i = 0; i < 8; i++) 
		   myImages[i] = getImage ( getDocumentBase(), "mountlogo" + i + ".gif");

		ButtonHandler bh;
		bh = new ButtonHandler ();

		Button go;
		go = new Button ("Go!");
		go.addActionListener (bh);

		add(go);
	}  // init

	private class ButtonHandler implements ActionListener {
		public void actionPerformed (ActionEvent event) {
			animate = 1;	// tell paint() to animate
			repaint ();
		}
	}



}  // program
