Structuring FLA Files
Structuring FLA Files
Creating FLA files that are consistent makes it easier to work with Flash on a regular basis. It is not uncommon to forget where you have placed particular elements, or what object instance code is placed on. Therefore, follow these guidelines to help you avoid frustrating issues.
Organizing Timelines and the Library
Frames and layers on a timeline are two important parts of the Flash authoring environment. These areas show you where assets are placed and determine how your document works. How a timeline and the library are set up and used affect the entire FLA file and its overall usability. The following guidelines help you author content efficiently, and let other authors who use your FLA documents have a greater understanding of how the document is structured:
Name layers. Give each layer an intuitive layer name, and place related assets together in the same location. Avoid using the default layer names (such as Layer 1, Layer 2), because it can be confusing to remember or locate assets when you are working on complex files. Clearly describe the purpose or content of each layer or folder when you name them in a FLA file. This helps users to quickly understand where particular assets are found in layers or folders.
If applicable, place your layers that include ActionScript and a layer for frame labels at the top of the layer stack in the timeline. For example, it is a good and common practice to name the layer that contains your ActionScript actions.
- Use layer folders. Use layer folders to group and organize similar layers. This makes it easy to locate the layers that include code and labels.
- Lock layers when necessary. Lock layers that you are not using or do not want to modify. Lock your ActionScript layer immediately so that symbol instances or media assets are not placed on that layer.
- Never put any instances or assets on a layer that includes ActionScript. This can potentially cause conflicts between assets on the Stage and ActionScript that references them. Because of this, keep all of your code on its own actions layer, and lock it after you create it.
- Use frame labels. If you reference frames in your code, use frame labels in a FLA file instead of using frame numbers in your ActionScript code. This is important and useful if those frames change later when you edit the timeline. If you use frame labels and move them on the timeline, you do not have to change any references in your code.
- Use library folders. Use folders in the library to organize similar elements (such as symbols and media assets) in a FLA file. If you name library folders consistently each time you create a file, it is much easier to remember where you put assets. Commonly used folder names are Buttons, MovieClips, Graphics, Assets, Components, and, sometimes, Classes.
Using scenes is similar to using several SWF files together to create a larger presentation. Each scene has a timeline. When the playhead reaches the final frame of a scene, the playhead progresses to the next scene. When you publish a SWF file, the timeline of each scene combines into a single timeline in the SWF file. After the SWF file compiles, it behaves as if you created the FLA file using one scene. Because of this behavior, avoid using scenes for the following reasons:
- Scenes can make documents confusing to edit, particularly in multiauthor environments. Anyone using the FLA document might have to search several scenes within a FLA file to locate code and assets. Consider loading content or using movie clips instead.
- Scenes often result in large SWF files. Using scenes encourages you to place more content in a single FLA file and hence, larger documents to work with and larger SWF files.
- Scenes force users to progressively download the entire SWF file, even if they do not plan or want to watch all of it. Your user progressively downloads the entire file, instead of loading the assets they actually want to see or use. If you avoid scenes, the user can control what content they download as they progress through your SWF file. This means that the user has more control over how much content they download, which is better for bandwidth management. One drawback is the requirement for managing a greater number of FLA documents.
- Scenes combined with ActionScript might produce unexpected results. Because each scene timeline is compressed onto a single timeline, you might encounter errors involving your ActionScript and scenes, which typically requires extra, complicated debugging.
There are some situations where few of these disadvantages apply, such as when you create lengthy animations. If you create lengthy animations, you might find it adventageous to use scenes. If disadvantages apply to your document, consider using multiple FLA files, movie clips, or screens to build an animation instead of using scenes. For more information on using screens, see Working with Screens in Flash Help or the Flash 8 LiveDocs (Using Flash > Working with Screens).
Saving Files and Version Control
When you save your FLA files, it is important to consider using a naming scheme for your documents. Most importantly, use a consistent naming scheme. This is particularly important if you save multiple versions of a single project.
Some problems might occur if you only work with one FLA file and do not save versions during the process of creating the file. It is possible that files might bloat in size because of the history that’s saved in the FLA file, or corrupt (as with any software you use) while you are working on the file. If any of these unfortunate events occur, you will have other versions of your file to use if you save multiple versions throughout your development.
You might also encounter problems when you create an application. Perhaps you made a series of changes to the file, and you do not want to use these changes. Or, you might delete parts of the file that you want to use later in your development. If you save multiple versions while developing, you have an earlier version available if you need to revert.
Use intuitive names for your files that are easy to read, are not cryptic, and work well online. Do not use spaces, capitalization, or special characters. Only use letters, numbers, dashes, and underscores. If you save multiple versions of the same file, devise a consistent numbering system such as menu01.swf, menu02.swf and so on. Many designers and developers choose to use all lowercase characters in their naming schemes, because some server software is case sensitive. Many Flash designers and developers adopt a naming system that uses a noun-verb or adjective-noun combination for naming files. Two examples of naming schemes are as follows: classplanning.swf and myproject.swf.
It is good practice to save new versions of a FLA file when you build an extensive project. The following are different ways that you can save new versions of files:
- Select File > Save As, and save a new version of your document.
- Use version control software (such as SourceSafe, CVS, or Subversion) or the Project panel to control your Flash documents. For more information, see “Projects and Version Control Guidelines“.
Note: SourceSafe on Windows is the only officially supported version control software that integrates with the Project panel. You can use other version control software packages with FLA documents, but not necessarily in the Project panel.
You can use several options to save a file: Save, Save As, and Save and Compact. When you save a file, Flash does not analyze all the data before creating an optimized version of the document. Instead, the changes you make to the document are appended to the end of the FLA file’s data, which shortens the time it takes to save the document. When you select Save As and type a new name for the file, Flash writes a new and optimized version of the file, which results in a smaller file size. When you select Save and Compact, Flash creates a new optimized file (removing the undo history) and deletes the original file.
Caution: When you select Save and Compact, you cannot undo any changes you made before you saved the file. If you select Save when working with a document, you can undo prior to that save point. Because Save and Compact deletes the earlier version of the file and replaces it with the optimized version, you cannot undo earlier changes.
Remember to frequently use Save As and type a new file name for your document after every milestone in your project if you are not using version control software to create backups of your FLA file. If you encounter major problems while working on the document, you have an earlier version to use instead of losing everything.
There are many software packages that allow users to use version control with their files, which enables teams to work efficiently and reduce errors (such as overwriting files or working on old versions of a document). Popular version control software programs include CVS, Perforce, Subversion, and SourceSafe. As with other documents, you can use these programs to organize the Flash documents outside Flash.