
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
306
|
Chapter 12: Using Components with ActionScript 2.0
We’ve now seen two different ways to handle events from components. For guid-
ance on which to use in various situations, see “Handling Component Events,” later
in this chapter.
The result TextArea component
Our interface is almost complete. We have a TextInput component that accepts a dol-
lar amount from the user, a ComboBox component that lets the user pick a currency,
and a button that triggers the conversion. All we need now is a TextArea component
in which to display currency conversion results. TextArea components are used to dis-
play one or more lines of text on screen within a bordered, adjustable rectangle.
Here’s the code that creates, sizes, and positions our TextArea component:
result = converter_mc.createClassObject(TextArea, "result", 5);
result.setSize(200, 25);
result.move(result.x, currencyPicker.y + currencyPicker.height + 10);
To prevent the user from changing the contents of the result TextArea component,
we set its
editable property to false (by default, TextArea component instances are
editable):
result.editable = false;
And that concludes the buildConverter( ) method. Let’s move on to the convert( )
method, which performs currency conversion.
Converting Currency Based on User Input
In the preceding section, we ...