Stick Page Forums Archive

[Flash] The Scarecrow's Button Tutorial (revised)

Started by: Scarecrow | Replies: 46 | Views: 10,956

Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Aug 28, 2006 11:08 AM #14127
The Scarecrow's button tutorial: Version 3.0

Updates since SP version:
- Added several parts
- Fixed up a few errors
- Improved understandibility
- Added contents (immediately below)

Updates since version 2.0:
- Added images (click on them to enlarge)
- Added examples



This tutorial will tell you:


- How to make a basic button
- How to make an animated button
- How to make a button carry out a basic function, such as go to another frame
- How to make a button link to a website


Throughout this tutorial, there are lots of small pieces of script. Script will be shown in blue, and parts of script that need to be customised will be red.

Explanations of the script will be green.


Introduction:
Welcome to my button tutorial! This tutorial will teach you how to make good buttons, and took ages to make. I hope it helps!



Creating a basic button:

Draw, say, a circle, or a piece of text that says 'Play' or something.

Image

This will be your play button.

Select it.

Press [F8] to make it a symbol.

Name it whatever you want, (something like 'button' or 'play' is recommended' and check the checkbox labelled 'Button'. Click OK.

Image

Double Click on your button to open up edit mode. You will see 4 frames at the top, all labelled.

The first is 'Up', then 'Over', then 'Down', and, finally, 'Hit'.

Image

'Up' is what will be seen when your mouse is NOT touching the button.

'Over' is what is shown when the mouse IS touching the button.

'Down' is what is shown when you click on the button and

'Hit' is the area that defines what part of the button can be clicked on.

Select the 'Hit' frame and press [F6] to add a keyframe. Now put a rectangle or something to say where you can click. You can leave this as just the same as your up frame, but if you have thin text, clicking can get annoying if there's no proper hit area.

Image

Press [F6] again on the 'Over' and 'Down' frames.

Now edit those frames to what you want for those particular parts.

Image

At the top of the screen, above the timeline, you will see something like 'Scene 1' '[button name]'. Click the one that says 'Scene 1' (or whatever the name of the scene you're working on is called) to return to the normal working stage.

Image

Put your button on the stage wherever you want. Assuming you are making a play button, it would go on the first frame, probably centered (using the align toolbar - ctrl + k).

Image

This will be your basic button. However, as there is no scripting, your button won't actually do anything. Continue to learn how to make it work.





Scripting for the button:

Hit F9. This opens the actions panel.

Make a new layer for actions (if there isn't already one).

On the frame of your movie that the button is on, and on the actions layer, enter the actionscript:
stop();

Image

(this only applies to those that want their movie to stop when it reaches the button)


Now select the button itself and enter this actionscript:
on(release){
play()
}


Image

The stop(); action stops the movie from playing.

The on(release){
play()
}

actions tell the computer that when the button is released, play the movie.



The finished product


More button scripts:

You could also choose to go to a designated frame by putting
on(release){
gotoAndPlay(
"Scene xxx", yyy)
}

(replace xxx with the scene name and
replace yyy with the frame number.

The script
gotoAndPlay("Scene xxx", yyy)
}

This script tells the movie to go to the selected scene and frame of that scene.



To make the movie go to, then STOP at a certain frame, replace gotoAndPlay with
gotoAndStop.




To make it go to the next frame, replace
("Scene xxx", yyy)
}
with
(nextFrame)
}


The script (nextFrame)
}
basically tells the movie to go to the next frame.



Or to make it go to the previous frame, replace
(nextFrame) with
(prevFrame).



The script (prevFrame) basically tells the movie to go to the previous frame.




Also, you can make a button send you to a website. To do this, use the button script:
on(release){
getURL('
http://www.awebsite.com');
}


The getURL('website'); script tells flash to open the website specified in the user's default browser.





Creating an animated button:

After turning an image into a button, changing the 'Hit' area, and adding keyframes, go to a frame that you want to animate, then select it's contents.

Hit F8, and make it a movie clip.

Image

Double click it to go to editing mode for the MC (movie clip).

Now you can animate it. If you want it to loop, just leave it as it is once you've animated, but if you want it to stop playing when the movie clip reaches a certain point (rather then continue playing indefinitely), make a new layer in the MC andput a keyframe where you want it to stop.

Select the keyframe, and open the actions panel.

Put the script
this.stop();
on it.

Image

This script tells the object you are working on (this.) to stop when it reaches this frame. A related piece of script is _root.. This tells flash that the next command is intended to work on the main movie.

You can repeat this process for the other frames (except 'hit', that would be stupid) and have your whole button animated.


The finished product

Now your button is animated! Yai!!1





Conclusion:

That's my tutorial for now, I may add more at some point, but this is all I can think of at the moments. Happy animating!

-The Scarecrow
Black Omen

Posts: 0
Joined: Aug 2025
Sep 2, 2006 2:37 AM #14423
Good tut, thanks. Helped me lots. But I have one question. When I made my play button and tested, when you put the mouse over the text, it shows the text cursor (like when you normally put the cursor over text in browser) and you couldn't click the text to play the movie and you had to click the edge of the button. How can I fix that?

Thanks again for the tut. :D
Paperclip

Posts: 840
Joined: Nov 2004
Rep: 500

View Profile
Sep 2, 2006 3:10 PM #14452
It's a nice tutorial but you need to add images.
Apples
2

Posts: 1,931
Joined: Dec 2005
Rep: 10

View Profile
Sep 2, 2006 7:47 PM #14468
Quote from Paperclip
It's a nice tutorial but you need to add images.

agree with paperclip all the time..... even if he says I suck.... which is half true :D very nice tut, helped me lots, just do what paperclip said.
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Sep 3, 2006 1:51 AM #14496
Well, in version three of this tut, images it shall have.


*edit*

Update'd to version 3.0! Also has previews now.
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Sep 3, 2006 5:50 AM #14510
lol, k

^.^


Did anyone notice my funky windows theme?
Black Omen

Posts: 0
Joined: Aug 2025
Sep 6, 2006 9:10 PM #14751
Why do I get ignored so much?! I need to know why it doesn't let me click on the text on my button when I test the movie! I don't know why it does it!!! Here is the animation if it helps.

Here it is. (Note: not only was it a button test, but a blood test as well, which is why it isn't long.)
See what I mean?
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Sep 7, 2006 4:46 AM #14784
Your 'hit' frame has no fill.
Evolution
2

Posts: 104
Joined: Jul 2006
Rep: 10

View Profile
Sep 7, 2006 5:16 PM #14790
sexy theme, whats it called.

nice tutorial keep it up.
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Sep 8, 2006 12:01 AM #14818
I haven't actually got a name for it yet.
Black Omen

Posts: 0
Joined: Aug 2025
Sep 8, 2006 12:26 AM #14824
What do you mean it doesn't have a fill in it? I tried doing the few things I thought of... like using a paint brush, or the fill thing. It does the same thing, how do I fix it???
Help appreciated. :)
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Sep 8, 2006 12:35 AM #14826
Send me the .fla, I'll fix it for you.
Black Omen

Posts: 0
Joined: Aug 2025
Sep 8, 2006 1:24 AM #14834
Ok, here it is, if this works...
EDIT: Yep, it worked. :D
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Sep 8, 2006 1:41 AM #14840
Change the text in the button from 'Dynamic text' to 'Static text'. It shoudl then work fine.

(in the properties panel)
Black Omen

Posts: 0
Joined: Aug 2025
Sep 8, 2006 9:30 PM #14872
Alright, I'll try it and tell ya how it works out. Thanks for the help :D
EDIT: Sorry it took a while, but I forgot to do it until now. :) Anyway, it HELPS, but it still puts the text cursor in spots, like if you slowly move the cursor from one side of the button to the other, it flashes from the text select cursor to the hand-thing (link select.) It does this extremely fast. Maybe I should just put "For best results, click the edge of the button." xD
Website Version: 1.0.4
© 2025 Max Games. All rights reserved.