GotoAndStop/Play
I am writing this to help me learn the functions of buttons. I am a total amature at flash so atleast I have learnt something.
This is the finished .swf file:http://hometown.aol.co.uk/YesUAreinYeshua/gotoandplay_gotoandstop.swf
Ok so I made an actionscript document, an I have done a simple animation with a triangle that rotates from pointing left to pointing right, with the colours changing. There are four keyframes in my document.
In the first keyframe I then hold down shift and select the two triangles(the orange and the red). I then right click and I goto “Convert to symbol…”. I choose button in the properties window that pops up and name the button “gotoandplay” because this is going to be our gotoAndPlay button.
I then goto the last frame and do that same. Holding down shift I select the two triangles(which are now green and blue). I then convert this to a button and name it “gotoandstop” as this is our gotoAndStop button.
I then go back and higlight the first keyframe and goto the actions window. This should say Actions-Frame at the top so that you know it is the frame actions. If not you have something higlighted on the stage and need to deselect it and then re-highlight the first keyframe.
In the actions box type “stop();”. This is our stop command and stops the document from playing past the first frame. I also put the “stop();” command in the actionscript box for the last keyframe. This is to stop it from playing past the last keyframe adn then looping back to the first keyframe.
Next I select the button name “gotoandplay” and go to the action box which should say Actions-Button. In the actionscript box I type “on(press) {gotoAndPlay(2);}”. On(press) means that when you click on the button with the mouse, it will perform the function in the “{ }” bracketts. The function in the “{ }” brackets is is “gotoAndPlay” in the brackets after this command you put the frame number that you want the button to goto. In our case this is frame 2. The gotoAndPlay function means that the button will goto and play an animation sequence.
Then I goto the last keyframe and I select the button which I named “gotoandstop”, this will be our “gotoAndStop” button. In the actionscript box I type “on(press){gotoAndStop(1);}”. As with the first button, the on(press) means that the command wont be carried out until the button is pressed by the mouse. Also, just like the gotoAndPlay function, the gotoAndStop function has a pair of brackets after it, in which you type the number of the keyframe you want to skip to, in this case keyframe 1. The gotoAndStop button is just like the gotoAndPlay button, only rather than going to a frame and then playing a movie, the gotoandStop button goes to a frame, and then stops.
Here is the flash file so you can play with it and edit:http://hometown.aol.co.uk/YesUAreinYeshua/gotoandplay_gotoandstop.fla