home *** CD-ROM | disk | FTP | other *** search
- import java.applet.AudioClip;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.StringTokenizer;
-
- class DelayedSoundArea extends ImageMapArea {
- URL sound;
- AudioClip soundData;
- boolean hasPlayed;
- int delay;
- int countDown;
-
- public void handleArg(String var1) {
- StringTokenizer var2 = new StringTokenizer(var1, ", ");
- this.delay = Integer.parseInt(var2.nextToken());
-
- try {
- this.sound = new URL(super.parent.getDocumentBase(), var2.nextToken());
- } catch (MalformedURLException var3) {
- this.sound = null;
- }
- }
-
- public void getMedia() {
- if (this.sound != null) {
- this.soundData = super.parent.getAudioClip(this.sound);
- }
-
- if (this.soundData == null) {
- System.out.println("DelayedSoundArea: Unable to load data " + this.sound);
- }
-
- }
-
- public void enter() {
- this.hasPlayed = false;
- this.countDown = this.delay;
- super.parent.startAnimation();
- }
-
- public boolean animate() {
- if (super.entered && !this.hasPlayed) {
- if (this.countDown > 0) {
- --this.countDown;
- return true;
- }
-
- this.hasPlayed = true;
- if (this.soundData != null) {
- this.soundData.play();
- }
- }
-
- return false;
- }
- }
-