Question about this script

Hi guys

can anyone tell me how to make this script works,

for example i have 3 frame and 3 buttons in the flash

when click button 2 from 1 frame and then it will do something
but if i click the button 2 from 3rd frame it will do something different.

another example
when click button 3 from 1 frame and then it will do something
but if click button 3 from 2 frame it will do something different.

thanks