
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
The CurrencyConverter Class
|
295
parameters: the movie clip to hold the currency converter (this) and the depth, hori-
zontal position, and vertical position—0, 150 and 100, respectively—at which to dis-
play the converter within the clip.
Our CurrencyConverter.fla file is now ready. We can now turn our attention to the
class that creates and manages the currency converter application itself,
CurrencyConverter.
The CurrencyConverter Class
The CurrencyConverter class’s three main duties are to:
• Provide a method that starts the application (main( ))
• Create the application interface
• Respond to user input
Before we examine the specific code required to perform those duties, you should
skim the entire class listing, presented in Example 12-1. For now, you don’t need to
read the code too carefully; we’ll study it in detail over the remainder of this chapter.
Example 12-1. The CurrencyConverter class
// Import the package containing the Flash UI components we're using.
import mx.controls.*;
// Define the CurrencyConverter class, and include the package path.
class org.moock.tools.CurrencyConverter {
// Hardcode the exchange rates for this example.
private static var rateUS:Number = 1.3205; // Rate for US dollar
private static var rateUK:Number = 2.1996; // Rate for pound sterling
private ...