This tutorial walks you through the steps of building a Flash project using a set of supplied assets and templates, and the Project panel. The goal is to build a photo gallery image viewer with thumbnail images that can be dragged and dropped onto a viewing area or controlled with forward and back buttons.
The tutorial focuses on the project development workflow, but I'll also touch on the general structure of the code package, manipulating the supplied code, and generating new custom features over the top of the template. Along the way you'll learn the physical structure of the FLA file as you build the project, and be able to edit the artwork as desired. In the end you'll have built a fully functional drag-and-drop interactive slideshow application and will have the project structure and knowledge needed to modify the template with different graphics.
Before you start, take a look at the completed sample on the introductory page to familiarize yourself with the features in the template.
Building a Flash project is easy to do. You start by creating a project folder and a strategy for structuring files and folders within it. From there you gather the artwork and assets you'll need before moving to Flash CS4.
Here are the steps in the workflow:
The following sections describe each of these steps and walk you through the workflow.
The first thing you need to do is plan the project. It's often tempting to jump right in and start working, but your project will be much easier to develop if you have an idea of what you're developing. I usually sketch thumbnail designs on a blank sheet of paper. My goal is to get some sense of how the user interface will fit together and, even more importantly, what elements make up the user interface. From there I can begin to envision how the FLA file should be set up and what ActionScript classes I need to develop.
In this tutorial I've already done the planning for you, so let's go over the big picture before moving forward. The structure of the photo gallery application is straightforward (see Figure 3). The Photo Gallery is designed as a dynamic application that loads a list of images from an external source. An XML file supplies the name of the images, which allows you to change the list without updating the SWF file. The Photo Gallery application itself consists of a FLA file and several ActionScript classes. Your goal in this tutorial is to develop the FLA file and published files using a supplied ActionScript package and source artwork file.

Figure 3. Diagram of the Photo Gallery project structure
Start the project by creating a project folder, gathering your media assets and artwork, and creating a FLA file. To speed things along, begin by downloading the flash_project.zip file, which contains all of the files necessary to start the project.
To create the project folder, follow these steps:
At this point you may want to add your own photos to the images folder that exists inside the project folder. The images folder already contains 12 default files that you can use while you are following the tutorial, but you can also add any number of your own.
To add your own images to the project:
Gather your images and format them to fit the project. For best results with the supplied template, optimize your images using the following properties:
Gather your user interface artwork and add it to the artwork folder. I've included an Adobe Illustrator file you can work with and modify as desired. You can also open this file in Adobe Fireworks CS4.
In this step, you'll set up the FLA file as the centerpiece of the project. The FLA file is the source file that compiles the ActionScript code into a SWF. Use the FLA file to visually design the user interface and bind visual assets to ActionScript functionality.
To create the FLA file:
Choose Modify > Document and update the document properties using the following settings:
Now you'll begin working with the Project panel. Although you can create projects from scratch using the Create Project option, the easiest way to generate a project is to use the Quick Project option. The Quick Project command automatically generates a Flash project based on the currently open FLA file in the Flash workspace. The project folder becomes the folder containing the FLA and the project assumes the name of the FLA. The Quick Project option is a great feature because it really allows you to move quickly.
To create a Flash project:
Select the Quick Project option from the Project Menu. Notice that the directory structure of the project folder populates the panel view (see Figure 4). Take a moment to explore the supplied assets.

Figure 4. Initial view of the Flash project
One of the things you'll notice while exploring the project view is that the files in the artwork and images folders are not displayed in the panel. This is because they contain files that are not a default Flash file type. However, you can show these files in the Project panel by adjusting the project properties settings. I like to enable all my project file types to appear in the Project panel view in order to visualize the project better and open the files using other programs.
To modify the project properties:
Enter the extension ai in the Change default filters field. Click the plus (+) icon to add the extension or check the .ai extension if it already exists in the file types list (see Figure 5).

Figure 5. Adding file types to the project using the Panel Preferences dialog box
Click OK to accept the changes. Now you can open the artwork and images folders to view the files (see Figure 6).

Figure 6. Project view showing the Illustrator file and JPEG images
Although you can design and modify vector artwork in the Flash workspace, I prefer to design my user interface elements in Adobe Illustrator. While working in Illustrator, I focus on defining the graphic layout. After it is finalized, I can import the artwork file into Flash—including the layer structure that I set up in Illustrator. The Import dialog box has become very powerful tool for importing vector artwork.
To import the Illustrator file and set up the FLA:
Review the main Timeline and Library (see Figure 7). By importing the Illustrator file, a great deal of the FLA file has been automatically built in Flash. This workflow is a great way to leverage a well-designed source file.

Figure 7. The Flash workspace as it appears after importing the Illustrator artwork file
The next step involves converting the artwork into symbols that correspond to the ActionScript components in the supplied src package. In a standard workflow you would create a movie clip in the Library to hold visual assets and then use the symbol's properties to link an ActionScript class to it. An ActionScript class is simply a text file containing code written in a package and class syntax. In this tutorial you will work with ActionScript by applying a prebuilt ActionScript class to a symbol's Class property. You can also generate an ActionScript class from scratch using the Project panel's ActionScript template feature.
The control buttons are a logical place to start. The ActionScript package contains a custom Button class that assigns simple button functionality to a movie clip including an optional toggle state. You can use the Button class repeatedly across multiple button movie clips if assigned to the symbol's Base class property.
To create the controls buttons, follow these steps:
While still in the Convert to symbol dialog box, click the Advanced button and then click the check box next to the Export for ActionScript option. Enter the following path in the Base class field (see Figure 8):

Figure 8. Settings for the button movie clip in the Convert to Symbol dialog box
Extend the symbol's timeline to Frame 20. Create an actions layer. Add a stop action to Frame 1 and then add three more keyframes, each spread apart by about 5 frames (see Figure 9).

Figure 9. Adding keyframes and frame labels to the PlayPauseBtn timeline
Name the instances on the Stage as follows:
To create the target and thumbnail components, follow these steps:
While the PhotoThumbnail symbol is selected, click the Create class icon in the Project panel. In the Create Class dialog box, enter the following settings:
While the symbol is still selected, click the Create class icon in the Project panel. In the Create Class dialog box, enter the following settings:
To create the timer indicator, follow these steps:
While the symbol is still selected, click the Create class icon in the Project panel. In the Create Class dialog box, enter the following settings:
At this point you've built all of the core elements of the application using the supplied assets. The next step is to define a document class and a system for building new component classes.
One of the great features of the Project panel is the ability to generate ActionScript files from a template. An ActionScript template is a predefined class structure that is copied into a new class file when it's created. This is a great time-saving feature because it allows you to create a new class from scratch. So with a little creativity, you can use the template feature to add a wide range of predefined class possibilities to your files as you create them.
The Project panel allows you to define two types of ActionScript template; one for classes linked to symbols in the Library and one for general classes. You can specify which templates to use by adjusting the Project properties in the Options menu. The templates folder in the project files contains two predefined templates designed to integrate with the ActionScript code package.
To view the ActionScript templates, follow these steps:
To assign the custom ActionScript templates to your project, follow these steps:
At this point you have a starting point for the scripts you'll create working with the supplied code package.
Now you're ready to build the document class. One of the first things the document class needs to do is to load an XML file defining the image paths for the photo gallery. Let's take a moment to define the XML file.
To create an XML data source, follow these steps:
The document class is an ActionScript class assigned to the main Timeline of an ActionScript 3 FLA file. I often use the document class as a controller for my applications. Its job is to load XML data, set up the controls on the screen, and respond to events broadcast from the controls.
To create a document class, follow these steps:
Click the Create Class icon on the Project panel. Apply the following settings:
To assign the document class to the main Timeline, select the empty Stage in order to display the Stage properties in the Property inspector. Enter the classpath to the PhotoGallery class:
Tip: If you run into problems when you test the movie, try comparing your files to the completed project files to see if you can identify the issue.
At this point you have a working project ready to be published. If you choose to add features and components to the template, use the boundClass_as3 ActionScript template to create the class and then add a bit of code to the document class to integrate the component.
For example, let's say that you want to add a status indicator to show the current image number out of the total number of images. The component itself is very simple; it's really just a text field inside of a movie clip. To accomplish this, the document class code will need to be updated to set the numeric values and position in the component in the z order of the objects on the screen.
To create the PhotoStatus component, follow these steps:
While the PhotoStatus symbol is selected in the Library, click the Create Class icon in the Project panel and enter the following properties:
Add the private _total variable to the class and update the getter setter functions to match the following code:
package src.gallery
{
import src.core.Component;
/**
* Class creates a status field component.
*
* @langversion ActionScript 3.0
* @playerversion Flash 9.0
* @tiptext
*/
public class PhotoStatus extends Component
{
//*********************************
// Properties:
private var _index:uint = 1;
private var _total:uint = 1;
//*********************************
// Initialization:
public function PhotoStatus():void
{
// Initialize...
}
//*********************************
// Properties:
public function get index():uint
{
return _index;
}
public function set index(i:uint):void
{
_index = i;
status_txt.text = "Image "+index+" of "+total;
}
public function get total():uint
{
return _total;
}
public function set total(i:uint):void
{
_total = i;
status_txt.text = "Image "+index+" of "+total;
}
}
}
Return to the PhotoGallery.as file and add the following code to the showImage function after line number 300:
// Update status status_mc.index = selectedIndex + 1; status_mc.total = imagesTotal; setChildIndex(status_mc, numChildren-1);
Publishing is the act of compiling the ActionScript code and FLA file into a SWF file. The Flash workspace also produces an HTML page by default that embeds the SWF on a web page.
To publish one or more files from the Project panel, follow these steps:
Set up your FLA file to export an HTML template with the allowFullScreen
parameter set to true. Choose File > Publish Settings and then click the
HTML tab. Change the HTML publish template settings as shown below (see Figure
10).

Figure 10. Selecting Flash Only – Allow Full Screen in the Publish Settings dialog box
When you're satisfied that the project is ready to be launched, you'll upload the published files to your server. The published files include:
Now that the project is published, you can always return to the Project panel and edit the PhotoGallery project whenever desired—as long as the Projects folder remains in the same location. If you need to move it, delete the project from the Project panel and then add it again after you move it.