Count number how many times button have been click

hi, how to count how many times the btn have been click. After counted the number of btn been click , according to the number , load the sound that match with the number of the btn been click.

i upload the fla zip file to here.anyone who know how to do it , plz reply me.thanks.

At the first frame :


Sound = new Sound();
Sound.attachSound("firstSound01.wav","secondSound02.wav");

At the btn's action:

on (release) {
count++;
trace(count);
if (count == 1) {
_root.Sound.start();
_root.Sound.firstSound01.start();
}
if (count == 2) {
_root.Sound.start();
_root.Sound.secondSound02.start();
}
//if (count == 3) {
// _root.Sound.start();
// _root.Sound.thirdSound03.start();
//}
//if (count ==4){
// _root.Sound.start();
// _root.Sound.forthSound04.start();
// count=""
//}
}

b’cos of the file is too big i can’t attach here,so i post the code here.With using these code, the sound come out when i click the btn is firstSound01.wav,the second time i click the btn the sound come out still firstSound01.wav.How to make it come out secondSound02.wav when i click the btn after first sound finish.

There are a few errors in your code. Try something like this:

//at the first frame
my_sound = new Sound(this);

//on the button
on (release) {
	count++;
	switch (count) {
	case 1 :
		id = "firstSound01.wav";
		break;
	case 2 :
		id = "secondSound02.wav";
		break;
	case 3 :
		id = "thirdSound03.wav";
		break;
	default :
		id = "forthSound04.wav";
	}
	_root.my_sound.attachSound(id);
	_root.my_sound.start(0, 1);
}

hi, it doesnt work.what is the mean of “id”? i use ur code to do it but it didnt give me any respone.

Yes it works.
*id * is a variable that controls which sound should play.
Did you give the linkage names to each sound file?

wat is the linkage name u mean??izzit where i should put in the first frame ?

To work with attached sounds you must to give a linkage name to the sound file in the library, so you can reference it.
Right click the sound file in the library, linkage, and check the export for actionscript option.

hi,the linkage which u told me i ady done when i import the sound file into the flash library.
so wat is the problem??is what i type for the sound fine name correct??

 
on(press){ 
  switch(mycounter){ 
	case 0: 
		id = "firstSound01.wav";
		break; 
	case 1: 
		id = "secondSound02.wav";
		break; 
	case 2: 
		id = "thirdSound03.wav";
		break; 
	 default: 
		id = "fourthSound04.wav";
		break; 
  } 
  mycounter++ 
}
 

What about the rest of the code i posted before?

hi, i dunno what the code u post for the rest , but anyway thanks for helping , i donw it already .

Did you pay attention to the code i posted before? The one you just posted is not the exact one i posted, so its never going to work.

sorry, cos i make changes ady.anyway thanks i done it.