Programming ActionScript 3.0: Example Files
Updated: June 5, 2006
This file describes the example source files provided for use with the book "Programming ActionScript 3.0". Each example is described in a chapter in the book. These examples are optimized for use with Adobe® Flex™ Builder™ 2.
Here is the list of examples distributed in this package:
Chapter | Example Application | Description |
---|---|---|
Chapter 2: Getting Started | Hello World Hello World Enhanced |
A simple "Hello World" application that shows the basics of how to use an ActionScript 3.0 class in an application. The Enhanced version adds a name-checking feature. These examples are meant to be built from scratch, tutorial-style. The example files are provided so you can see how they should look when completed. |
Chapter 4: Object-Oriented Programming | Geometric Shapes | Uses the object-oriented concepts of class inheritance and the implementation of interfaces to provide an application that calculates values for simple geometric shapes. |
Chapter 5: Display Programming | Sprite Arranger | Adds graphical Sprite objects to a drawing area and let you manipulate their placement in the display list. Builds upon the classes from the geometric Shapes example. |
Chapter 6: Working with Dates and Times | Simple Clock | Displays a simple analog clock face using methods of the Date and flash.util.Timer classes. |
Chapter 7: Working with Strings | ASCII Art | Loads bitmap images and coverts them into ASCII character equivalents, using a number of the methods in the String class. |
Chapter 8: Working with Arrays | Play List | Demonstrates a number of methods of the Array class while building and presenting a play list of music files. |
Chapter 9: Handling Errors | Custom Errors | Presents a simple framework containing a set of custom ApplicationError classes and shows how to throw, catch, and handle such errors. |
Chapter 10: Using Regular Expressions | Wiki Editor | Uses regular expressions to convert text containing wiki-style codes into formatted HTML text. Also shows how to use regular expressions for other conversions, such as numeric calculations. |
Chapter 11: Working With XML | RSS Viewer | Reads an RSS feed and formats the entries as HTML, including hyperlinks to the stories being referenced. This example shows the powerful new E4X statements and operators in action. |
Chapter 13: Event Handling | Alarm Clock | Demonstrates how to define, dispatch, and handle custom event classes. Extends the Simple Clock application to create an Alarm Clock with specialized AlarmEvents. |
Chapter 14: Networking and Communications | File I/O | Shows how to use the FileReference class to upload files from your local disk to a remote server, and how to download files from a remote server to your local disk. Note: To run this example you will need to set the UPLOAD_URL and DOWNLOAD_URL variables in the code to the address of a web server that will accept uploads and allow downloads. |
Telnet Socket | Connects to a Telnet server and shows how to send and read bytes from the socket connection. Note: To run this example you will need to have access to a running Telnet server. |
|
Chapter 15: Working with Geometry | Display Object Transformer | Uses methods of the flash.geom.Matrix class to apply multiple geometric transformations to a DisplayObject. |
Chapter 16: Client System Environment | Capabilities Info | Lists the capabilities of your current browser and operating system, by using the SystemCapabilities class and an ExternalInterface call that uses Javascript to retrieve browser properties. |
Chapter 19: Using the External API | IntrovertIM_CSharp IntrovertIM_HTML |
A tiny instant messenger application the uses the flash.external.ExternalInterface class to send messages between a Flex/ActionScript application and an external application. Two versions are provided. One uses HTML and Javascript for the external application, and the other uses C#. |
Running the Example Applications in Flex Builder
Each example folder includes an MXML file, one or more ActionScript source files, and optionally some additional text or image files needed by the example application. The focus of each example is on its ActionScript classes.
The MXML file generally provides a simple user interface while the ActionScript classes demonstrate interesting features of ActionScript language. The ActionScript classes are all in packages whose names are structured like this: com.example.programmingas3.nameofsample.
If you are new to ActionScript 3.0 and Flex Builder 2, we recommend reading the first two chapters of the Programming ActionScript 3.0 book before loading the rest of these examples. Chapter 2 of the book steps through how to build the "Hello World" example in some detail, using Flex Builder 2.
To install and run an example application using Flex Builder 2:
- From the File menu in Flex Builder 2, select New... > Flex Project
- In the first panel of the New Flex Project wizard, select the option"Basic (e.g. XML or web service from PHP/JSP/ASP.NET)" then click on the Next button.
- On the next panel, click on the "Use default location" check box so it becomes un-selected. Then click the Browse... button. Navigate to a folder on your local drive or local network that contains one of the examples and then click OK. The location of the folder you selected will appear in the Folder: field.
- Type the name of the example you selected into the Project Name field. For example, if you selected the HelloWorld example folder, type "HelloWorld" into the Project Name field. Then click the Next button.
- The next panel lets you select the name of the MXML application file for the project. In most cases, the default name that's already showing in the Main Application File field will be the correct one, but you should always make sure. To do so, click on the Browse... button next to the "Main application file" field. Click on the file name that you see in the list and then click on the OK button. The rest of the default values in this panel should be fine.
- Click the Finish button to create the project files.
- The main application's MXML file should now be showing in the Flex Builder 2 editor window. To run this application, click the Run button in the toolbar. The icon for the Run button shows a white triangle inside green circle. The example application should then open in your web browser.