ActionScript 3 samples for Flash CS4 Professional
These ActionScript 3 samples demonstrate various features common in Flash CS4 Professional development. Some samples are complete applications, while others simply introduce a concept that you can use to build your own apps. Use these files to investigate how each of the samples was constructed. Explore the graphics and timelines in the FLA files, and explore the ActionScript code in the associated AS files.
Samples are rated Beginner, Intermediate, and Advanced. Intermediate developers and people with prior experience in ActionScript 2 will be interested in looking at the code to see how it works in ActionScript 3.
Get the source FLA files for all samples:
- flash_as3_samples.zip (ZIP, 10.1 MB)
You can also download individual source files on each sample's detail page below.
Note: You may reuse these files as you want, but they are not officially supported as part of the product. Technical support will not be able to answer any questions about these files.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
The samples and related concepts are grouped into the following categories:
Drawing samples
ActionScript 3 has access to most aspects of the SWF environment. The first step to understanding how to work with ActionScript 3 is to understand how it relates to the visual environment. SWF applications are composed of timelines (movie clips or sprites) that act as containers for content and code. In ActionScript 3, timelines are display object containers and the visual elements within them are called display objects. The following samples explore timelines, coordinate space, and ActionScript built-in drawing and color controls:
User level: Beginner
Coordinate space, radians, and degrees
Explore timeline coordinates and the distance and angle between points.
User level: Beginner
Movie clip nesting
Explore the effects of timeline nesting and graphic placement within timelines.
User level: Intermediate
Drawing API
Explore the built-in drawing tools available in sprites and movie clips.
User level: Beginner
3D rotation
Explore the effects of animating two-dimensional objects in 3D space.
Media samples
Sounds, images, and text can be used to enhance the content in your project. Adobe Flash Player has the ability to use external or embedded media. ActionScript 3 has greater control over media usage and media related events. The following samples highlight how to use text, images, and sound in your project:
User level: Intermediate
Dynamic text
Explore a simple paycheck calculator that uses Flash text fields and component text inputs to display dynamic text.
User level: Intermediate
Sound loading
Explore a sample that loads sounds and provides a basic set of custom controls.
User level: Intermediate to advanced
Sound channels
Explore more in-depth sound controls in this mixing board sample.
User level: Intermediate
Dynamic sound generation
Explore the new sound generation capabilities of Flash Player 10.
Component samples
One of the strengths of ActionScript is its ability to create organized, reusable components. Flash CS4 Professional ships with a set of built-in user interface components for ActionScript 2 and ActionScript 3. You can also build your own custom components. The following sample shows built-in and custom components in action:
User level: Beginner to intermediate
Custom components
Explore a custom-built ArcadeButton component with author-time Live Preview.
Note: To learn more about components, check out the Components Learning Guide for Flash CS4 Professional.
Time samples
There are many occasions when you need to know the viewer's local time and date or the elapsed time in a movie (SWF file). Displaying the date and time in a user interface or the elapsed time during a game or interaction is an easy way to generate interest and a sense of change. The following samples show two approaches for handling time:
Interactivity samples
Flash CS4 Professional is a great tool for building games, learning interactions, and interactive environments. ActionScript 3 expands the options available to developers, allowing for creative solutions to old design problems. You can use the built-in components or build custom controls to create interactive elements in your movie. The following samples create animations through a series of interactive controls:
User level: Intermediate
Button-controlled movement
Explore an interactive screen where an animation is controlled by buttons.
User level: Intermediate
Slider-controlled movement
Explore an interactive screen where an animation is controlled by sliders.
User level: Intermediate
Joystick-controlled movement
Explore an interactive screen where an animation is controlled by a virtual joystick.
User level: Intermediate
Keyboard-controlled movement
Explore an interactive screen where an animation is controlled by keyboard presses.
User level: Intermediate
Click-controlled movement
Explore an interactive screen where an animation is controlled by click location.
User level: Intermediate
Object thrust
Explore an interactive screen where keyboard controls change the thrust of an animation.
User level: Intermediate
Scrolling background
Explore an interactive screen where sliders control a dynamically generated sky background.
User level: Intermediate
Inverse kinematics
Explore an animation built with the new inverse kinematics feature in Flash CS4.
Game samples
The SWF format is a popular medium for online game development due to its history in animation, strength with graphics, and its integrated programming language. The following samples combine previous concepts to form more complex game applications: