Handling button events (Flash Professional Only)
21
6.
Type the following code in the Actions panel:
on(press) {
trace("You pressed Button 1");
}
on(release) {
trace("You released Button 1");
}
on(rollOver) {
trace("Button 1 has focus");
}
on(rollOut) {
trace("Button 1 lost focus");
}
7.
Drag another instance of the same button to the Stage and position it directly below the
first button.
8.
With the second button selected on the Stage, open the Actions panel and enter the
following code:
on(press) {
trace("You pressed Button 2");
}
on(release) {
trace("You released Button 2");
}
on(rollOver) {
trace("Button 2 has focus");
}
on(rollOut) {
trace("Button 2 lost focus");
}
9.
In the Timeline, select Frame 1 on the ActionScript layer.
10.
Type the following code in the Actions panel:
_focusRect = false;
This disables the yellow focus rectangle that Flash Lite draws around the button with
focus. In this case, the default focus rectangle is unnecessary because the button’s contains
an Over state that is displayed when it has focus.