What Can ActionScript Do?

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Preface

ActionScript is used to create all kinds of interactive applications, typically for web-based use. Here are just a few possibilities: an MP3 player, a multiuser drawing application, a 3D walkthrough of a home, an online store, a message board, an HTML editor, and the game Pac-Man. Each of these applications uses a combination of ActionScript's capabilities, a sampling of which follows. Begin thinking about how you can combine these techniques to build your applications.

Timeline Control

Flash movies are composed of frames residing in a linear sequence called the timeline. Using ActionScript, we can control the playback of a movie's timeline, play segments of a movie, display a particular frame, halt a movie's playback, loop animations, and synchronize animated content. Movie clips within a main movie each have their own timeline.

Interactivity

Flash movies can accept and respond to user input. Using ActionScript, we can create interactive elements such as:

  • Buttons that react to mouseclicks (e.g., a classic navigation button)

  • GUI elements such as list boxes, combo boxes (a.k.a. drop-down menus), and check boxes

  • Content that animates based on mouse movements (e.g., a mouse trailer)

  • Objects that can be moved via the mouse or keyboard (e.g., a car in a driving game)

  • Text fields that display information on screen or allow users to supply input to a movie (e.g., a fill-in form)

Visual and Audio Content Control

ActionScript can be used to examine or modify the properties of the audio and visual content in a movie. For example, we can change an object's color and location, reduce a sound's volume, or set the font face of a text block. We can also modify these properties repeatedly over time to produce unique behaviors such as animated effects, physics-based motion, and collision detection.

Programmatic Content Generation

Using ActionScript, we can generate visual and audio content directly from a movie's Library or by duplicating existing content on the Stage. In Flash MX, we can use the MovieClip class's Drawing API, createEmptyMovieClip( ) method, and createTextField( ) method to create graphics and text from scratch at runtime. Programmatically generated content may serve as a strictly static element such as a random visual pattern or as an interactive element such as a button in a dialog box, an enemy spaceship in a video game, or an option in a pull-down menu.

Server Communication

One of the most common ways to extend Flash's functionality is via communication with some server-side application or script, such as Macromedia ColdFusion MX or a Perl script. Although communicating with ColdFusion is largely the purview of Macromedia Flash Remoting MX (Flash Remoting), the core ActionScript language provides a wide variety of tools for sending information to, and receiving information from, any server-side application or script (e.g., Java, PHP, ASP, etc.). The following applications all involve server communication:

Link to a web page

See getURL( ).

Guest book

See the LoadVars and XML classes, Chapter 17, and The Code Depot, described in the next section.

Chat application

See the XMLSocket class and the example at http://www.moock.org/chat.

Multiplayer networked game

See the XMLSocket class and http://www.moock.org/unity.

E-commerce transaction

See the LoadVars and XML classes.

Personalized site involving user registration and login

See the LoadVars and XML classes.

Detailed implementations of even this limited number of potential ActionScript applications are beyond the scope of this book. Instead, our goal is to give you the fundamental skills to explore the myriad other possibilities on your own. This is not a recipe book it's a lesson in cooking code from scratch. What's on the menu is up to you.

     



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net