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:

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.

Creative Commons License
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:

Drawing 1: Coordinate space, radians, and degrees
User level: Beginner
Coordinate space, radians, and degrees
Explore timeline coordinates and the distance and angle between points.

Drawing 2: Movie clip nesting
User level: Beginner
Movie clip nesting
Explore the effects of timeline nesting and graphic placement within timelines.

Drawing 3: Drawing API
User level: Intermediate
Drawing API
Explore the built-in drawing tools available in sprites and movie clips.


Drawing 4: Color transformations
User level: Intermediate
Color transformations
Explore color transformations on display objects.

Drawing 5: 3D rotation
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:

Media 1: Dynamic text
User level: Intermediate
Dynamic text
Explore a simple paycheck calculator that uses Flash text fields and component text inputs to display dynamic text.

Media 2: Image loading
User level: Beginner
Image loading
Explore a simple image loader and slide show application.

Media 3: Image masking
User level: Beginner
Image masking
Explore three types of masking effects used over bitmap images.


Media 4: Sound loading
User level: Intermediate
Sound loading
Explore a sample that loads sounds and provides a basic set of custom controls.

Media 5: Sound channels
User level: Intermediate to advanced
Sound channels
Explore more in-depth sound controls in this mixing board sample.

Media 5: Dynamic sound generation
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:

Component 1: Video
User level: Beginner
Video
Explore video playback using the ActionScript 3 FLVPlayback component.

Component 2: Custom components
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:

Time 1: Timer
User level: Intermediate
Timer
Explore an example of a stopwatch-style timer.

Time 2: Clock
User level: Beginner
Clock
Explore an example of a clock that displays the computer's local 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:

Interactivity 1: Button controlled movement
User level: Intermediate
Button-controlled movement
Explore an interactive screen where an animation is controlled by buttons.

Interactivity 2: Slider controlled movement
User level: Intermediate
Slider-controlled movement
Explore an interactive screen where an animation is controlled by sliders.

Interactivity 3: Joystick controlled movement
User level: Intermediate
Joystick-controlled movement
Explore an interactive screen where an animation is controlled by a virtual joystick.


Interactivity 4: Keyboard controlled movement
User level: Intermediate
Keyboard-controlled movement
Explore an interactive screen where an animation is controlled by keyboard presses.

Interactivity 5: Click controlled movement
User level: Intermediate
Click-controlled movement
Explore an interactive screen where an animation is controlled by click location.

Interactivity 6: Object thrust
User level: Intermediate
Object thrust
Explore an interactive screen where keyboard controls change the thrust of an animation.


Interactivity 7: Scrolling background
User level: Intermediate
Scrolling background
Explore an interactive screen where sliders control a dynamically generated sky background.

Interactivity 8: Inverse kinematics
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:

Game 1: Maze
User level: Intermediate
Maze
Explore a maze game where arrow keystrokes control player movement through the boundaries of a maze pattern.

Game 2: Amoebas
User level: Advanced
Amoebas
Explore a starship game where obstacles and laser fire are dynamically generated through building game levels.

原文地址:https://www.cnblogs.com/top5/p/1660092.html