Writing Scripts and Creating Applications in Flash MX 2004 and Flash 8
Writing Scripts and Creating Applications in Flash MX 2004 and Flash 8
The scripting improvements in Flash Basic 8 and Flash Professional 8 provide better performance, flexibility, and ease of use. The ActionScript editor (Actions panel and Script window) has several new features and changed user interface elements that improve how you write and edit ActionScript code in Flash.
You can now select Hidden Characters in the Actions panel and Script window to view or hide hidden characters when you’re writing script files in the Actions panel or Script window. This option shows spaces, tabs, and line breaks within your scripts (see Figure 14). If you accidentally add a hidden character that causes a compiler error (such as double-byte spaces), this feature can help you locate the problem.
You can reload modified script files when working on an application. A warning message appears, prompting you to reload the modified script files associated with the application you’re working on. This feature is particularly beneficial to teams working on applications at the same time because it helps you avoid working with outdated scripts or overwriting newer versions of a script. If a script file was moved or deleted, a warning message appears and prompts you to save the files as necessary.
You can delete ASO files while you create, or when you test, your application. This helps you work with the latest version of your application’s class files because it removes cached files that are out of date. Select Control > Delete ASO Files or Control > Delete ASO Files and Test Movie.
Changes to Debugging
There are a few changes to the debugging workflow in Flash 8. Debugging options are now available in the Script window, as well as the Actions panel for ActionScript files. You can now add breakpoints when you’re editing ActionScript (AS) files. The breakpoint information is stored in an XML document within the Configuration directory to keep track of breakpoints between your debugging sessions.
ActionScript in Flash MX 2004 and Flash 8
ExternalInterface) and file input and output (
New Capabilities in ActionScript
This section highlights some of the new capabilities that have been added to ActionScript 2.0 in Flash 8. In addition to the new classes and features mentioned in this section, there are numerous additional methods and properties you will want to play with. For more details on individual methods and properties, search the Flash Help panel (F1) for the particular topic.
A robust new capability of Flash Player is that you can load new kinds of image files at runtime, such as progressive JPEG images and non-animated GIF and PNG files. If you load an animated file, the first frame of that animation appears in the SWF file.
Bitmap caching lets you improve the performance of your applications at runtime by caching a bitmap representation of your vector button or movie clip instances at runtime. You can use ActionScript code to access this property or select the instance and then select an option in the Property inspector to cache the instance. Caching a movie clip as a bitmap prevents Flash Player from having to redraw the image continually, providing a significant improvement in playback performance.
Alpha channel masking is supported if both the mask and the maskee movie clips use bitmap caching. This support also lets you use a filter on the mask independently of the filter that is applied to the maskee itself.
Note: Mask layers do not support alpha channel masking. You must use ActionScript code to apply a mask and use runtime bitmap caching.
The 9-slice scaling feature enables you to scale movie clip instances without widening the strokes that outline the movie clip. You can use ActionScript code or the Flash user interface to access this feature in either Flash Basic 8 or Flash Professional 8.
Note: To use the 9-slice scaling feature with a symbol, select the symbol in the library and then select Properties from the options menu. Click the Advanced button (if applicable) and select Enable Guides for 9-Slice Scaling.
The 9-slice scaling feature is especially useful for creating components. To see this feature in use, open the FLA files for the FLVPlayback component and its skins, which use the 9-slice scaling feature. You can find numerous examples in this directory:
(Windows) Hard DiskProgram FilesMacromediaFlash 8<language>ConfigurationSkinFLA
(Mac OS X) HD/Applications/Macromedia Flash 8/Configuration/SkinFLA
The workflow for creating accessible applications is improved. Flash Player 8 no longer requires developers to add all objects to the tab index for content to be read correctly by a screen reader. For more information on tab index, see Button.tabIndex, MovieClip.tabIndex, or TextField.tabIndex in the ActionScript 2.0 Language Reference.
- You can pass any number of arguments, with any names; you aren’t limited to passing a command and arguments
- You can pass various data types (such as Boolean, Number, and String); you are no longer limited to String parameters
- You can now receive the value of a call, which returns immediately to ActionScript (as the return value of the call you make)
FileReference class is new in Flash 8. It lets you add the ability to upload and download files between a client and server from a SWF file. Your users are prompted to select a file to upload or a location for download in a dialog box (such as the Open dialog box in Windows).
New Classes, Methods, and Properties in Flash 8
The ActionScript language has grown and developed since its introduction several years ago. With each new release of Flash, additional keywords, objects, methods, and other language elements were added to ActionScript.
Table 2 lists classes and language elements new or changed in Flash 8 and supported in Flash Player 8. For more information on these classes and language elements, search the Flash Help panel (F1).
||flash.filters||Adds bevel effects to objects|
||flash.display||Creates and manipulates arbitrarily sized transparent or opaque bitmap images|
||flash.display||Acts as a base class for filter effects|
||flash.filters||Applies blurs to objects in Flash|
||flash.filters||Applies transformations to ARGB colors and alpha values|
||flash.geom||Adjusts color values in movie clips (
||flash.filters||Applies matrix convolution filter effects|
||flash.filters||Uses pixel values from a BitmapData object to perform displacement on an object|
||flash.filters||Adds drop shadows to objects|
||flash.net||Uploads and downloads files between the user’s computer and a server|
||flash.net||Selects one or more files to upload|
||flash.filters||Adds glow effects to objects|
||flash.filters||Adds gradient bevels to objects|
||flash.filters||Adds gradient glow effects to objects|
||Manipulates the operating system’s input method editor (IME) within Flash Player|
||mx.lang||Controls how multilanguage text appears in a SWF file|
||flash.geom||Represents a transformation matrix that determines how to map points from one coordinate space to another|
||flash.geom||Represents a location in a two-dimensional coordinate system (x represents the horizontal axis and y represents the vertical axis)|
||flash.geom||Creates and modifies Rectangle objects|
||flash.text||Provides functionality for anti-aliasing embedded fonts|
||flash.geom||Collects data about color transformations and coordinates manipulations that you apply to a
Note: Official support is added for the
AsBroadcaster class in Flash 8. This class was not officially supported in Flash MX 2004.