...

View Full Version : Getting sound to work with jcreator



pineappelle
12-14-2011, 06:33 PM
i have this code and i want to make the sound work. right now the sound isnt working. the sound file is in the right folders and the picture is working


/**
* @(#)chapter11random.java
*
* chapter11random Applet application
*
* @author
* @version 1.00 2011/12/12
*/

import java.awt.*;
import java.applet.*;

public class chapter11random extends Applet {

Graphics screen;
Image mypicture;
AudioClip mysound;
int x, xmove, running;

public void init() {

mypicture=getImage(getCodeBase(),"pineapple.jpg");
mysound=getAudioClip(getCodeBase(),"newemail.wav");
x=40;
xmove=1;
running=1;

}

public void makesound() {

mysound.play();

}

public void paint(Graphics screen) {

while (running<300) {
screen.drawImage(mypicture,x,30,100,100,this);
for (int i=1;i<30000000;i++) {
}
screen.setColor(Color.white);
screen.fillRect(x,30,100,100);
if(x<0||x>400) {
xmove=xmove*-1;
mysound.play();
}
x=x+xmove;
}

}
}

Zviko
12-27-2011, 12:57 PM
Funny enough i had the same problem, my friend fixed it for me. I will see if i can get results from him:confused:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum