type = 'application/x-shockwave-flash'
data = 'http://sitepointstatic.com/flash/button.swf'
width = '400'
height = '400'
bgcolor = 'black'

Download the sample files here.

You can use Macromedia Flash UI components to quickly and easily add simple user interface elements to your Flash document.

In this tutorial, we’ll look at how easy it is to use the button component.

1. Open the components panel by clicking ctrl+f7.

2. Drag the Push Button component onto the stage.

3. Select the Push Button component in Frame 1. The component’s parameters are displayed in the Property inspector.

4. To name the component, type "btn1" in the Property inspector Instance Name text box.

5. Type "f1" to name the Click Handler. Later you can write ActionScript to define exactly what the Click Handler should do.


6. Select the first key frame from the existing layer, and press f9 to open the actions box.

7. Insert the following action:

function f1(name) 
if(name == btn1)
{btn1.setLabel("Button Pressed ")}

This action is simple — when you press the button, it calls the function f1().

8. The function has a parameter name which takes the Instance name of the button — in this case, btn1.

9. The If condition checks to see if the event is from btn1. If it is from btn1, it sets the label of button to "Button presed".

This is just a simple example. You can insert any number of events in the If block — experiment and see what you come up with!

Georgina has more than fifteen years' experience writing and editing for web, print and voice. With a background in marketing and a passion for words, the time Georgina spent with companies like Sausage Software and sitepoint.com cemented her lasting interest in the media, persuasion, and communications culture.

No Reader comments

Special Offer
Free course!

Git into it! Bonus course Introduction to Git is yours when you take up a free 14 day SitePoint Premium trial.