ABSTRACT

The class uses a TextField object and a getter/setter combination to assign text to it. You might wonder why we didn’t simply use a standard text fi eld instead of a custom class. You very well could for an example as straightforward as this, but there are a couple of reasons to encapsulate it as its own class. First is the ability to defi ne constants, such as what the default value of the text fi eld should be when no clue is shown. Another reason is expandability and fl exibility; by already having a class set up to handle the clue, it will be easier to add animation and other features without adding a lot of code to the puzzle class. One other reason you might not expect is that it is easier to set up a text fi eld inside Flash rather than code. Custom fonts (basically, anything other than system fonts) are clumsily handled through ActionScript and require more hassle than simply creating a symbol with a TextField object inside it and linking it to a class. In fact, spawning a new TextField from scratch in code and assigning it formatting objects and positioning involve as much or more code than the class we just created.