Place four Buttons on the
ControlBar named Front, Right, Left, and Side (Figure 6-26).
Figure 6-26. Adding four Buttons to the ControlBar
132
CHAPTER 6
We??™ll use these four buttons to control the view of the watch. Let??™s create a function that essentially runs
the gotoAndStop code that is used in Flash but made to work in Flex. Figure 6-27 shows the function.
Figure 6-27. Function for controlling the current frame in Watch
12. Copy this code into your MXML Source view.
When called, this function tells the Watch
to go to the frame label that is used.
13. For each of the buttons, call the function
from the OnClick event with the appropriate
label. For the front button, set OnClick
to goToLabel('front'); for the side button,
set it to goToLabel('side'); for the
left button, set it to goToLabel('left');
and for the right button, set it to
goToLabel('side'). Give each button an
ID that is the same as its label. Once you??™ve
done that, test your movie. Figure 6-28
shows the application in action.
Figure 6-28. Final application
Summary
With that function, Flex has taken control of what was originally Flash content. You are not limited to
button clicks for this kind of interaction. Any Flex event, such as a state change or a change in data,
can call a function, and so cause a change in content originally created in Flash.
In the next chapter we look more closely at programming with ActionScript in Flex Builder.
133
FLEX BUILDER AND FLASH
What we??™ll cover in this chapter:
Overview of object-oriented programming
ActionScript 3.
Pages:
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102