home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / WDESAMPL.BIN / DelayedSoundArea.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-11-19  |  1.8 KB  |  57 lines

  1. import java.applet.AudioClip;
  2. import java.net.MalformedURLException;
  3. import java.net.URL;
  4. import java.util.StringTokenizer;
  5.  
  6. class DelayedSoundArea extends ImageMapArea {
  7.    URL sound;
  8.    AudioClip soundData;
  9.    boolean hasPlayed;
  10.    int delay;
  11.    int countDown;
  12.  
  13.    public void handleArg(String var1) {
  14.       StringTokenizer var2 = new StringTokenizer(var1, ", ");
  15.       this.delay = Integer.parseInt(var2.nextToken());
  16.  
  17.       try {
  18.          this.sound = new URL(super.parent.getDocumentBase(), var2.nextToken());
  19.       } catch (MalformedURLException var3) {
  20.          this.sound = null;
  21.       }
  22.    }
  23.  
  24.    public void getMedia() {
  25.       if (this.sound != null) {
  26.          this.soundData = super.parent.getAudioClip(this.sound);
  27.       }
  28.  
  29.       if (this.soundData == null) {
  30.          System.out.println("DelayedSoundArea: Unable to load data " + this.sound);
  31.       }
  32.  
  33.    }
  34.  
  35.    public void enter() {
  36.       this.hasPlayed = false;
  37.       this.countDown = this.delay;
  38.       super.parent.startAnimation();
  39.    }
  40.  
  41.    public boolean animate() {
  42.       if (super.entered && !this.hasPlayed) {
  43.          if (this.countDown > 0) {
  44.             --this.countDown;
  45.             return true;
  46.          }
  47.  
  48.          this.hasPlayed = true;
  49.          if (this.soundData != null) {
  50.             this.soundData.play();
  51.          }
  52.       }
  53.  
  54.       return false;
  55.    }
  56. }
  57.