Download (direct link):
Using DHTML with Flash
Of course, not all solutions are black or white. You could have created a solution thatís primarily HTML-based, but one specific portion of the project is an entire Flash-based mini-site. You can also use some crafty workarounds to get beyond some of the limitations that were mentioned earlier. You can combine a core Flash Web site with other multimedia technologies such as RealPlayer and QuickTime by layering multimedia content on top of the Flash content.
Part I ¶ Conceptualizing Flash
Figure 3-4: Flash movies within a core Flash Web site
Considering Data Architecture Solutions
After you have defined the way (or ways) in which you will integrate Flash into your project, you need to determine how to integrate any external data with your project. The topic of external data was introduced in Chapter 2. Here, the methods you can use to store all data are emphasized, both internally (that is, within the Flash movie, SWF file) and externally (that is, outside of the Flash movie, SWF file).
Internal Data Storage
When you develop a project in Flash, you probably need to store a lot of information within the movie. Following is a short list of common data that you might store in Flash movies:
¶ URLs: You may want to store frequently used URLs as variables, and use these variables in loading actions such as getURL(), loadMovie(), loadVariables(), and the new LoadVars object. These URLs can be the domain name, without any specific resource, such as:
var serverPath:String = "http://search.mydomain.com";
¶ Object placement: The X and Y coordinates of MovieClip objects on the stage can be stored in Flash movies. These values can be used to place Movie Clips in specific places at certain points in the Flash movieís playback.
¶ File paths and names: You can store the names of other Flash movie files and their location paths as variables in the Flash movie. For example, you may want to store additional SWF files in a folder named ďassetsĒ on your Web server. You can use a variable named assetPath to refer to this path. This way, any changes to the actual location can be made directly to the assetPath variable.
Chapter 3 ¶ Architecture for Flash Movies
¶ Initialization data: This is any information that tells your Flash movie how to behave when the movie begins playback, such as setting up navigation bars with default menu choices or telling a tutorial movie to play on a userís very first time to the site.
¶ Interactive functionality: As simple as it sounds, all ActionScript code must be parsed within the SWF file. The Flash Player cannot load or compile ActionScript code from external sources such as text files or server-side scripts.
As you become more familiar with Flash ActionScripting, you will find that other types of data will need to be stored (or calculated) internally.
If you don't know what a variable is, don't worry. Variables are discussed at length in Chapter 5.
Since Flash 5, you have the ability to create generic code objects that are appropriately named the Object class. Objects are created directly in ActionScript. Objects are most useful for storing data that is descriptive, such as color, sound, and text properties.
To learn more about the Object class in ActionScript, read Chapter 7.
External Data Storage
As discussed in the Chapter 2, Flash movies can load data from external sources, as long as the data is formatted correctly. Some types of data that can be stored internally in Flash movies can be stored externally as well.
Data Storage in SWF or Other Asset Files
You can use other SWF files to store data. Using loadMovie() actions, you can load this data only when it is required by the user for a particular task. Here, any material that is loaded into a Flash movie is considered to be data. Some common uses of SWF files as data containers include the following:
¶ Individual media files: In order to keep file sizes down, you can elect to load graphics and sounds as separate SWF, JPEG, MP3, or FLV files. For example, if you have a soundtrack player, you can dynamically load songs as they are requested. This prevents the user from spending long periods of time waiting for one large download containing all the sounds.
¶ Shared libraries: Since Flash Player 5, the Flash Player can use runtime shared libraries, which are special SWF files that contain reusable elements such as fonts and Movie Clips. You can share one SWF file across several SWF files required for a Flash Web site. Flash MX introduced a distinction between author-time and runtime shared libraries. Author-time libraries allow the elements within libraries to be easily updated and swapped among any Flash document (FLA file) on your network or computer. Runtime shared libraries can be used to store elements that are included in multiple live SWF files. When a change is made to the original, shared symbols among the documents can be automatically or manually updated.
48 Part I ¶ Conceptualizing Flash