There are choices when using buttons and frames. When adding actions to buttons there is a dropdown box on the second line on the right side of the actions panel. There you will find choices like: go to next frame, go to previous frame, ect...just select either and the code is written for you...