All the files and examples discussed in this chapter are available for download from the book's web site (

Generator and JGenerator content begins with the use of the Generator authoring extensions that are included with the Flash 5 authoring environment. The extensions consist of Generator objects and commands that allow you to dynamically create and/or modify Flash movie elements on the server or desktop. This is an important point to remember. Generator templates are processed before they are sent to the Flash Player, unlike ActionScript, which is processed within the Flash Player.


Remember, Generator templates are processed on the server-side, before the movie is sent to the Flash Player.

ActionScript is processed on the client side in the Flash Player, after the movie has been loaded from the server.

To demonstrate how you can use Generator to place complex Flash elements into your movie and to present a better picture of the Generator content authoring process, we will walk through the process of creating a simple pie chart using the authoring extensions.


At the time that this was written, JGenerator did not have support for the Generator chart objects, including the Pie Chart object.

However, support for these objects is being worked on, and by the time you read this, JGenerator should have support for the chart objects.

  1. Open Flash and create a new movie. Save the movie and name it pie.fla .

  2. In the same directory that you saved pie.fla, create a text file called pie_data.txt . This file holds the data used to build the pie chart.

  3. Open the Generator Objects Panel by selecting Window, Generator Objects. This window contains all the Generator objects (see Figure 10.1).

    Figure 10.1. The Generator Objects panel.


    Select the Pie Chart object, and drag it onto the movie stage. You will see a square, with Pie Chart in the top-left corner. This is the placeholder for the pie chart. The generated chart will be placed in the location of the placeholder, and will inherit all the properties of the placeholder, such as its x and y scale, alpha, and rotation.

  4. After you have placed the Pie Chart object in the movie, open the Generator Properties Panel (see Figure 10.2) by double-clicking on the Pie Chart object on the stage or selecting the object in the movie and going to Window, Panels, Generator.

    Figure 10.2. Generator Properties panel for the Pie Chart object.


    This window contains the properties used to create the object, and allows you to customize how the generated element (in this case a pie chart) will look and behave. We are not going to worry about customizing the look of the pie chart right now. All we want to do is to specify the data source for the pie chart.

  5. In the Data Source section of the Properties window enter pie_data.txt , and then save the Flash movie.

  6. Open the pie_data.txt file with a text editor (such as Notepad or BBEdit), and enter the following data:

     value, color, url  2, blue, ""  7, green, ""  3, yellow, "" 

    At this point it is not important to understand the format of this file (we will discuss it in a little more detail later in the chapter), except to note that the first row contains the column names, and each subsequent row is a related set of data. It is very similar to a database record set.

  7. Save the text file and switch back to the Flash application.

  8. Be sure that the movie is set to be published as a Generator template by opening the Publish Settings window (File, Publish Settings) and checking the Generator Template (SWT) box.

  9. You are now ready to test the movie. Select Control, Test Movie. You should see a pie chart similar to Figure 10.3.

    Figure 10.3. A simple pie chart created with Generator.


If you do not see a pie chart:

  • Check the output window (Window, Output) for any error messages.

  • Be sure that the pie.fla and pie_data.txt file are in the same directory.

  • Check that the pie chart's data source property is set correctly.

  • Make sure that the data source contains the correct data, with no missing commas, or line returns.

  • Be sure that the movie is set to publish as a Generator template.

It is a pretty simple pie chart, but you can adjust the pie chart's settings in the Generator Inspector Properties window and further customize how the chart looks and works.

If you look in the directory that contains the FLA for the pie chart, you should find a file named pie.swt that was created when you tested the movie. SWT files are Generator templates and are used by the Generator server to dynamically create Flash or other graphic media. This is an important point. Once you have created a Generator template, a Generator server must process the template in order to create a Flash movie (or other media file).

Here is a summary of the Generator workflow:

  1. Create content using the Generator authoring extensions within the Flash-authoring environment.

  2. Publish the file and create a Flash movie (SWF), and a Generator template (SWT).

  3. Use the Flash file (SWF) by itself, or copy the Generator template (SWT) to the Generator server to dynamically create the movie.

To dynamically process the templates, you would need to install the Generator server, and serve the templates from the server. However, that is beyond the scope of this chapter.

Macromedia Flash Enabled. Flash Design and Development for Devices
Macromedia Flash Enabled. Flash Design and Development for Devices
ISBN: 735711771
Year: 2002
Pages: 178 © 2008-2017.
If you may any questions please contact us: