
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
300
|
Chapter 12: Objects and Classes
Drawing the current content of the screen is often the responsibility of a separate
class that deals specifically with the screen and graphical user interface. How the
screen is drawn, when it is drawn, and what draws the screen can vary greatly from
application to application. For example, in our Quiz at the end of this chapter, we’ll
update the screen from a QuizGUI class every time a question is displayed. But, in
other applications, a ball object would probably move around a lot, so it would need
to be displayed repeatedly via either MovieClip.onEnterFrame( ) or setInterval( ).
Here are the major issues to consider when designing an application’s display
system.
• First decide whether the display elements will render themselves or be rendered
by a central class. For example, will the Ball class provide its own drawBall( )
method, or will there be a drawBalls( ) or drawScreen( ) method on some other
class?
• Decide how often the elements should be displayed—either when some event
occurs (such as a mouse click) or repeatedly (as fast as frames are displayed in
the Flash Player).
• Decide on the rendering technique. Each visual element in a Flash movie must
be displayed in a movie clip. However, movie clips can be placed manually at
authoring time,