Specifically, the ability to move an application
around your screen and the ability to close an application are controlled through the window.
We can re-create this functionality in our application.
Re-creating the functionality
Let??™s start with the ability to close an application. We do this by importing the close event and creating
a function to run the event. Use the code shown in Figure 12-33.
259
FLEX AND AIR
Figure 12-33. ActionScript that allows the
window to be closed
6. Add the import command after the previous import commands close to the start of the
tag. Add the close function to the end of the other functions that exist in the project.
Remember that all ActionScript must be placed within the tags.
7. Add a button to run this code. The button uses the OnClick event to call the function close(),
as shown in Figure 12-34.
Figure 12-34. Button that closes the window
Adding the drag functionality
The ability to drag the application through the background image is also created by a function. The
code is shown in Figure 12-35.
Figure 12-35. Functions that allow the application to be dragged
260
CHAPTER 12
As you can see, this code consists of two functions. The first creates a listener so that we know when
the mouse is clicked on the background image. The second changes the position of the window based
on the mouse movements.
8. Add this code at the bottom of the previous functions within the tags.
Pages:
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173