/*****************************************************************
** DemoSoundArray - demo arrays of objects
**
** Note: For this applet to work, ten audio clip files named
** 0.au, 1.au, 2.au, 3.au, 4.au, 5.au, 6.au, 7.au, 8.au, and 9.au
** must be stored in a directory named 'sounds'.  This directory
** must be a subdirectory from the directory where the applet
** is stored.
**
** (c) Scott MacKenzie, 2000                             
******************************************************************/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class DemoSoundArray extends Applet implements ActionListener
{
   private static final int MAX = 10;
   private AudioClip[] tone = new AudioClip[MAX];
   private Button[] beep = new Button[MAX];

   public void init()
   {
      for (int i = 0; i < MAX; i++)
      {
         String soundFile = "sounds\\" + i + ".au";
         tone[i] = getAudioClip(getDocumentBase(), soundFile);
         beep[i] = new Button("Beep " + i);
         beep[i].addActionListener(this);
         add(beep[i]);
      }
   }

   public void actionPerformed(ActionEvent ae)
   {
      for (int i = 0; i < MAX; i++)
         if (ae.getSource() == beep[i])
            tone[i].play();   
   }
}  

