PDA

View Full Version : My first tutorial ^^: GotoAndStop/Play


snowykittenz
07-14-2005, 04:34 AM
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

Lewwy
07-14-2005, 06:52 AM
Im glad that are trying a tutorial. I think it would be easier to follow with images. And more people wanting to know how to do this would actually try with the inclusion of images to help them.

Did you know about this : http://www.kirupa.com/developer/mx2004/jump_frames.htm

snowykittenz
07-14-2005, 07:10 AM
Im glad that are trying a tutorial. I think it would be easier to follow with images. And more people wanting to know how to do this would actually try with the inclusion of images to help them.

Did you know about this : http://www.kirupa.com/developer/mx2004/jump_frames.htm

wow cool, no i sure didnt.
also whats the difference between on(release) and on(press)?

Lewwy
07-14-2005, 07:12 AM
on(press)
This means that as soon as the mouse click goes down, the action is launched.

on(release)
This means that once the mouse click goes down, nothing happens, but when you lift your finger (release) the action is performed :) .

Seb Hughes
07-14-2005, 11:16 AM
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

This is a easy topic, but for sombody new and me aswell it was confusing maybe pics like mentioned earlier

Vexir
07-14-2005, 11:41 AM
Images are a must :) A very basic topic although you never know who might need it :) I find myself often browsing tutorial sites and not finding tutorials on the barebone basics! Annoying and frustrating. Try not to make your paragraphs too lengthy, the way I like to write my tutorials ( I don't for Kirupa.com but I used to for a lot of other sites ) is I write them so that a person with ADD could follow it fairly easily... this means clear cut words, not so much funny side stuff that can distract the user, long lengthy paragraphs broken up into multiple little ones.. little things like that go a long way :) Kirupa.com tutorials are a great example... most of the tutorials anyways.