views:

75

answers:

1
 private final int NUM_SOUND_FILES = 4;
 private Random rnd = new Random(4);
 private int mfile[] = new mfile[NUM_SOUND_FILES]; //the second mfile 
                                                      //reports error everytime
 mfile[0] = R.raw.sound1;
 mfile[1] = R.raw.sound2;
 mfile[2] = R.raw.sound3;
 mfile[3] = R.raw.sound4;

 int sndToPlay = rnd.nextInt(NUM_SOUND_FILES);

I keep getting syntax errors no matter how I write it. And when I get the syntax right, it forcecloses. Here's with the alleged "correct" syntax but forcecloses:

private final int NUM_SOUND_FILES = 4;
private Random rnd = new Random(4);
private int mfile[] = new int[NUM_SOUND_FILES];{
mfile[0] = R.raw.sound1;
mfile[1] = R.raw.sound2;
mfile[2] = R.raw.sound3;
mfile[3] = R.raw.sound4;}
+2  A: 

I'm not an android developer but that array declaration on line 3 doesn't look right to me, normally its an array of type int which would be declared as below:

private int[] mfile = new int[NUM_SOUND_FILES];
Mauro
I got it working thanks to a guy named Mark...the whole code needed a little reworking...only trouble I'm having now is the sound not restarting when another .create is made...this is gonna be harder than I thought :P
Aaron
might be a good idea to put the working code on as the answer, you can accept your own answer if its the closest fix.
Mauro