Accessibility

Table of Contents

Flex best practices – Part 2: Development practices

Handling assets

Flex applications typically incorporate a collection of files, including several different types of media, such as images, CSS files, fonts, audio clips, and video, to name a few. Keeping the application's assets and source code organized can save time when requests to change the software later surface. Here are some general guidelines to consider when naming and storing the files associated with your Flex application.

checkmark Create and use an "assets" directory

The common best practice is to create a folder titled "assets" and store it inside the src directory. The src directory is created by Flex Builder during the Flex project setup.

Thus, the root of your asset directory path will be: src/assets

checkmarkUse subdirectories inside the assets directory

To help organize the many type of media your application can use, I recommend that you organize subdirectories logically based on the types of media files in use. The following points highlight some commonly used practices for subdirectories.

checkmarkUse a SWF directory

Consider keeping the SWF files in your Flex application stored in a directory named "SWF".  You may want to use a different directory depending on the purpose of the SWF files being loaded into the application. Modules, for example, may be kept elsewhere. Modules are beyond the scope of this article but more information can be found here: Writing modules.

The SWF directory path will be: src/assets/swf

checkmark Use an images directory

Store image assets such as JPG, GIF, or PNG files in a directory named "images".

The image directory path will be: src/assets/images

checkmark Use a fonts directory

Flex applications can contain embedded typefaces. When using nonstandard fonts for your Flex application store the TTF files and other font files in a directory named "fonts". Also keep in mind that font availability varies across platforms. Including the fonts is a good idea especially if the development team works on different platforms.

The font directory path will be: src/assets/fonts

checkmark Use an audio directory

Audio is a commonly used media type in rich Internet applications. Store audio assets such as MP4 and WAV files in a directory named "audio".

The audio directory path will be: src/assets/audio

checkmark Use a video directory

Store videos in a directory named "video" 

The video directory path will be: src/assets/video

checkmark Use an XML directory

If your application contains XML configuration files or XML files that will be loaded directly into the application without making a call to a server, keep them grouped together in a directory named "xml".

The xml directory path will be: src/assets/xml

The directory structure shown in Figure 1 illustrates these conventions.

Use subdirectories to organize assets

Figure 1. Use subdirectories to organize assets