Tutorial:Buttons
From Anipedia
Contents |
[edit] Buttons
A button is flash is mainly used to start an animation. A play button. They can also be used to got to a certain scene, pause a movie, or show subtitles.
[edit] Making a button
To start, just draw any object with any tool. Right click and click on convert to symbol. Select the Button option and name your button whatever you want. The button will appear in your library. Double-click on it. You will see it is different from a normal Movie Clip or Graphic object. There are four main frames. Up, Over, Down, and Hit.UP - How button looks when first shown.
OVER - How button looks when cursor is over it.
DOWN - How button looks when pressed.
HIT - The area the viewer will have to click to press the button. This will not be visible in the actual flash.
[edit] Coding Buttons
[edit] Play Button
As early stated, button can be used to do various stuff in flash. It's mostly used to start a movie. The code for that (depending on your preloader) is below. When coding, press enter where it says *enter*
on (release) { *enter* _root.play(); *enter* }
on (release) means that after the cursor has click on it and stops clicking the button works. You could also use, on (press) so that as soon as the cursor clicks the button the button does its stuff.
_root. refers to the main timeline. So that when the button is clicked and let go of, the button will play what is next on the main timeline.
[edit] Flash Link button
Also commonly used for scene selection or to go somewhere else in the flash is...
on (release) { *enter* gotoAndPlay(2); *enter* }
The most important part of that is gotoAndPlay(2);.
gotoAndPlay tells it to go to that frame and play it. You could also put in stop, so it will go to the frame and stop.
(2); refers to frame 2. So it will go to and play frame 2. Instead, you could put in "framename". So if you had a frame called framename it would go to and play frame framename.
It is extremely useful!
[edit] URL Button
URL Buttons are used to, so when clicked on, they will link to a website. Code for this is...
on (release) { *enter* getURL("www.newgrounds.com"); *enter* }
getURL tells it pull up a website.
("www.newgrounds.com") tells it to bring up Newgrounds.com.


