For
example, in Chapter 12 we create a media center that works with videos, using the class VideoPlayer.
In this case, the statement looks like Figure 7-21.
Figure 7-21. The import statement
Figure 7-20.
Character data
section
147
ACTIONSCRIPT IN FLEX
Maintaining your code
Comments are pieces of text that are added to the code to help a person looking at the code to make
more sense of it faster. These are extra statements that the computer ignores but that help us understand
what is happening in the code. These comments are ways of communicating to the people that
may be reading the code. They allow the person who created the code to explain it, mentioning bugs
or kludged pieces of code along the way. This becomes especially important when developing in a
team or if you return to the code after a period of time. As an extra bonus, comments can be used to
generate documentation. A program called ASDoc (included in the Flex SDK) can read specific markers
in comment blocks and convert them to HTML files.
Figure 7-22 shows two ways of putting comments into code. There is no difference between the two
forms of commenting except that one is easier for single lines and the other is better for larger pieces
of text.
Figure 7-22. Two ways of adding comments
Controlling flow with events
Both ActionScript 3.0 and Flex are based on an event model. By that, we mean that all interaction,
method invocation, and so forth are generally handled by associating a specific event with it.
Pages:
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119