MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 252

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

For more information on class members (also called static properties), see
properties" on page
249.
A sample file on your hard disk demonstrates how to create a dynamic menu with XML data
and a custom class file. The sample calls the ActionScript
two parameters: the path to the XML menu file and a reference to the current timeline. The
rest of the functionality resides in a custom class file, XmlMenu.as.
You can find the sample source file, xmlmenu.fla, in the Samples folder on your hard disk.
On Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\XML_Menu.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/XML_Menu.
Using the Singleton design pattern
A common way to use class members is with the Singleton design pattern. A design pattern
defines a formal approach for structuring your code. Typically, you might structure a design
pattern as a solution for a common programming problem. There are many established design
patterns, such as Singleton. The Singleton design pattern makes sure that a class has only one
instance and provides a way of globally accessing the instance. For detailed information on the
Singleton design pattern, see
design_patterns.html.
Often you encounter situations when you need exactly one object of a particular type in a
system. For example, in a chess game, there is only one chessboard, and in a country, there is
only one capital city. Even though there is only one object, you should encapsulate the
functionality of this object in a class. However, you might need to manage and access the one
instance of that object. Using a global variable is one way to do this, but global variables are
not desirable for most projects. A better approach is to make the class manage the single
instance of the object itself using class members. The following example shows a typical
Singleton design pattern usage, where the Singleton instance is created only once.
252
Classes
www.macromedia.com/devnet/mx/coldfusion/articles/
"Static methods and
constructor and passes it
XmlMenu()

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

This manual is also suitable for:

Flash 8

Table of Contents