Graphics Reference
In-Depth Information
TIP
Best practices for package naming conventions are to use the top-level
domain first (com, net, org, and so on) followed by the company name or
site domain (com.flashadbook for flashadbook.com). Beyond that, your
package names should break down to specific sections or functionalities
such as utils, events, or engines.
Package declaration occurs at the beginning of your class file
with the directory path in dot notation. For example, using the
directories mentioned in the previous section, your package
declarations would be as follows: com.flashadbook.base , com.
flashadbook.display , com.flashadbook.engines , com.flashadbook.
events ,and com.flashadbook.utils .Whilethedisplay,events,and
utils are pretty standard packages to use for certain kinds of classes,
I also have an engines package that contains the MemoryGame engine
from the next chapter and the base package that contains Docu-
ment classes used to show examples of these classes. What
'
sa
'
Document class? Let
s take a look.
Document Class
Rather than placing any code on the timeline of my .fla, I
ve created
a separate Document class for each sample. For example, in order
to implement the BorderButton class, I
'
ve created a BorderButton-
SampleclassthatisusedastheDocumentclassofa.flafile.This
way, you can work with a single .fla in which you only need to
change the Document class to create a completely different output
.swf based on the examples. There are also several other benefits to
using a Document class, including the fact that it allows a developer
to work on the code while a designer works in the .fla file, or that
you can extend your code much more easily if it doesn
'
'
t live on the
timeline. How about adding the ability to do things like reuse your
code in a Flex project even after it was originally written for a Flash
project? When you start looking at these and the many other bene-
fits, it
s very much worth keeping the code in a Document class.
The next question then is how to tie a Document class to a .fla,
and the answer is that you have two choices. One option is through
the Advanced ActionScript 3.0 Settings, and the other is through
the Properties window of the .fla. To set the Document class via the
Advanced ActionScript 3.0 Settings, go to the File menu and select
'
Publish Settings.
From the resulting window, make sure the box
next to
Flash (.swf)
is checked and choose the tab labeled
Flash.
Within the Flash tab, make sure
ActionScript 3.0
is selected in the
drop-down labeled
button. Finally,
in the Advanced ActionScript 3.0 Settings window, type in the
path to the class you would like to use as the main code for the .fla
(see Fig. 12.2).
Script
and click the
Settings
…”
Search WWH ::




Custom Search