Flash Script – Checkbox Component


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

Utilizing the checkbox component is easy.

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

2. Drag the checkbox component onto the stage, and select the checkbox component in Frame 1. The component’s parameters will be displayed in the Property inspector.

3. Type "cbox" into the Property inspector Instance Name text box, to name the component.

4. Next, we need to specify whether we want the initial state of the CheckBox component to be selected or unselected.

To have the checkbox autonatically appear selected, access the Initial Value parameter pop-up menu, and select "True".

5. In the Label Placement parameter pop-up menu, check that the default value is set to right alignment. This ensures the label will be displayed to the right of the checkbox.

6. Type "f1" for the Click Handler name. Later, of ocurse, you will write ActionScript to define what the Click Handler should do.

7. Select the first key frame from the existing layer. Press f9 to open the actions box, and insert the following action:

function f1() 
{
cbox.setLabel("Checked")  
}

8. The above action is simple. When you click on the checkbox, it calls the function f1(). This function sets the label of checkbox to "Checked". It’s that simple!

Download the sample files here.

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

No Reader comments

Comments on this post are closed.