We use the native 3D methods available in Flash Player 10 as well as several custom ActionScript 3 classes to construct an advertising billboard with a 3D twist. The billboard is fully customizable by editing a simple XML file.
- Download all files corresponding to this tutorial: cs4billboard.zip
The zip package contains all 'fla', 'as', 'xml', and 'jpeg' files corresponding to this tutorial. All the source files are well-commented with instructions for customization.
An Overview of the Code
The BillboardCS4 class in the package flashandmath.as3 does all the work of creating and spinning any instance of your billboard. As we show on the next page, you pass to the constructor of the class the data for the images to be displayed, URLs of pages that open in a new window as the user clicks on an image, and the number of vertical slices. The images can be of any size as long as they are all of the same size.
For maximum flexibilty and easy customization, we placed all the other code in a Document Class called 'BillboardMain'. You simply enter the name of the class in the Document Class field of your 'fla' file (ours is cs4billboard.fla). You can adjust the dimensions of the Stage and place the text on the Stage that you want.
The BillboardMain class begins with loading the billboard.xml file. This simple xml file contains information about the location and names of your images, the corresponding URLs to which they link as the user clicks (if any), as well as the number of vertical slices and the time between consecutive transitions. Thus, by simple edits on the Stage of the 'fla' file and easy changes to billboard.xml, you can create your own billboard of any size.
The BillboardMain file loads images specified in the billboard.xml file at runtime using our custom AS3 class ImageLoader.
On the next page, we show how to customize the xml file and discuss public methods of the billboard.