| Basic usage of swfc | Fonts | Shapes | ActionScript | >Buttons< | Blend Modes | Filters |
5.Buttons
Actionscript comes in handy when dealing with SWF Buttons.
A button defines, in SWF context, an object sensitive to mouse movement, mouse buttons, and key presses.
The following is a trivial example: Four objects which change their shape once the cursor is over it.
Code listing 5.1 |
||
.flash filename="button1.swf" fps=50
.box box1 color=white fill=#336633 width=50 height=50
.box box2 color=white fill=#99cc99 width=100 height=100
.button mybutton1
.show box1 as=shape x=25 y=25
.show box2 as=hover x=12.5 y=12.5
.end
.frame 1
.put b1=mybutton1
.put b2=mybutton1 x=100 red=+255
.put b3=mybutton1 y=100 green=+255
.put b4=mybutton1 x=100 y=100 blue=+255
.end
|
The .show command (which can only be used inside .button) has a syntax very similar to .put. For every shape a button uses, you can specify the position, color transform, scaling, rotation etc. just like with .put.
The only real difference between those two commands is the as parameter: with that you tell the button when to display that specific shape. There are four allowed parameters to as:
| Previous: ActionScript | SWFC Manual: Buttons | Next: Blend Modes |