Migrating from Macromedia Flash MX to Flash MX 2004
Tim Statler
Macromedia
This article discusses the new features in Macromedia Flash MX 2004 and Flash MX Professional 2004, how they compare to similar features in Macromedia Flash MX, and how you can migrate your projects from Flash MX to Flash MX 2004. It also describes the new runtime features and behaviors in Flash Player 7 and the considerations you need to address when publishing existing content from Flash Player 6 format to Flash Player 7.
In many cases, migrating projects is a transparent procedure. For example, if your work consists mainly of animation and simple ActionScript commands, transitioning to Flash MX 2004 will likely be seamless. In other cases, you might want to reauthor Flash MX content using the new authoring and runtime features available in Flash MX 2004, such as the new Halo components, new video authoring and playback features, or the object-oriented programming features in ActionScript 2.0. Perhaps you've heard about the new case-sensitivity rules in Flash Player 7 and wonder how it might affect your scripts.
Read onward to learn the facts you need to make informed decisions for transitioning from Flash MX to Flash MX 2004.
ActionScript in Flash MX and Flash MX 2004
ActionScript, the scripting language for Macromedia Flash, has evolved incrementally over several releases. In the Flash MX 2004 release, ActionScript has changed enough to warrant calling it ActionScript 2.0.
ActionScript 2.0 doesn't replace ActionScript 1.0 or provide runtime features not available in ActionScript 1.0. Rather, it comprises a new set of language elements that make writing object-oriented programs much easier. With the introduction of keywords such as class, interface, extends, and implements, ActionScript 2.0 provides a formal model for writing object-oriented code—one that will be familiar to programmers who have worked with Java, JavaScript 2.0, or C#.
In addition to a new object-oriented programming model, ActionScript 2.0 provides strict data typing on variables, function parameters, and return types, as well as enhanced compiler errors and warnings that make debugging your code much easier.
ActionScript 2.0 code runs in Flash Player 6 and later. If you're targeting Flash Player 5, stick with ActionScript 1.0.
Migrating Projects to ActionScript 2.0 and Flash Player 7
You don't have to use ActionScript 2.0 to write scripts in Flash MX 2004. Any ActionScript you wrote in previous versions of Flash work in Flash MX 2004. You can continue to write code using the same techniques and language elements you're used to.
There are some situations, however, where you might want to consider migrating legacy code and projects to Flash MX 2004 and Flash Player 7:
- You're creating a large-scale Flash application or presentation that contains a lot of code. Using ActionScript 2.0 helps speed the development and debugging process.
- You've created object-oriented programs in ActionScript in Flash MX or Flash 5 and want to upgrade your code to ActionScript 2.0. This makes maintaining and modifying your code much easier.
- You're interested in object-oriented programming (OOP) and want to learn about it in a familiar authoring environment.
You can combine ActionScript 1.0 and ActionScript 2.0 code in the same project, as long as you specify ActionScript 2.0 in the publish settings for your Flash document (see the next section).
Publishing to ActionScript 2.0 and ActionScript 1.0
Macromedia Flash MX 2004 has a compiler for each version of ActionScript. You specify the ActionScript version in a Flash document's Publish Setting dialog box. By default, ActionScript 2.0 is the selected ActionScript version (see Figure 1).
Figure 1. Publish Settings dialog box in Flash MX 2004
The ActionScript 2.0 compiler compiles all ActionScript 1.0 code, with the following exception: the "slash syntax" used to indicate movie clip paths (for example, parentClip/testMC:varName= "hello world") generates compilation errors if ActionScript 2.0 is selected as the ActionScript version.
To resolve this problem, either rewrite your code using dot (.) notation in place of slashes or select the ActionScript 1.0 compiler.
Creating Classes with ActionScript 2.0
The main distinction between ActionScript 2.0 and 1.0 is a formal approach to object-oriented programming. If you've ever programmed with Java, JavaScript 2.0, or C#, you can easily apply your knowledge to learning ActionScript 2.0. If you're new to OOP in general, learning ActionScript 2.0 will provide you with skills you can apply to other languages.
Some important points to remember about creating classes with ActionScript 2.0 include the following:
- ActionScript 2.0 classes can only reside in external ActionScript (AS) files. For example, you can't define a class in a frame or button script inside a FLA file. The Script window in Flash Professional lets you easily create and edit external class files without leaving the Flash authoring environment. If you're using the standard edition of Flash MX 2004, you can use your preferred text or code editor to create AS class files.
- The name of an AS class file must match the name of the class it contains. For example, if you create an ActionScript 2.0 class named "MyClass," then the AS file that contains that class must be named "MyClass.as."
Below is an example of a class created using ActionScript 2.0:
// Circle class using ActionScript 2.0
class Circle extends Shape {
var radius:Number;
function Circle(radius:Number) {
this.radius = radius;
}
function setRadius(radius:Number):Void {
this.radius = radius;
}
}
And below is the same Circle class defined using ActionScript 1.0:
// Circle class using ActionScript 1.0
function Circle (radius) {
this.radius = radius;
}
Circle.prototype = new Shape();
Circle.prototype.setRadius = function (radius) {
this.radius = radius;
}
Although this is a simple example, it's clear that ActionScript 2.0 provides a more intuitive programming model than ActionScript 1.0 for creating classes. Note the use of strict data typing in the ActionScript 2.0 example to indicate variable types, as well as function parameter and function return value types. For more information on strict data typing, see the next section.
For a complete discussion of creating classes with ActionScript 2.0, see Creating Classes with ActionScript 2.0 in the ActionScript Reference Guide.
Strict Data Typing in ActionScript 2.0
One feature that distinguishes ActionScript 2.0 from ActionScript 1.0 is strict data typing, which is the ability to specify the kind of data that can be assigned to a variable, passed to a function as a parameter, or returned by a function. Data typing enables the ActionScript 2.0 compiler to provide more thorough debugging information than was possible using ActionScript 1.0. You can use strict data typing in your FLA scripts and external class files.
To specify a data type for a variable, function parameter, or return type, you use colon (:) syntax. For example, the following code indicates that the variable xPosition is a Number data type:
var xPosition:Number;
If at some other point in the script you assign a value to xPosition that is not a Number data type, the ActionScript 2.0 compiler generates an error.
In addition to typing variables, you can also type function parameters and return types. For example, the following function expects a parameter of type String and returns a Number:
function stringToNum(numString:String):Number {
//
}
Note that strict data typing is a compile-time only feature. Flash Player does not enforce strict data typing at runtime.
Case-Sensitivity in ActionScript 2.0 and Flash Player 7
Macromedia implemented several changes in Flash Player 7 to conform more closely to the ECMA-262 Edition 4 Proposal. For a full list of these changes in Flash Player 7, see ECMA-262 Edition 4 Compliance in the ActionScript Reference Guide.
Most significantly, Flash Player 7 is now case-sensitive when interpreting variable and function names. This means, for example, that two variables whose names are different only in case (foo and Foo) are interpreted as being different variables in Flash Player 7. In Flash Player 6 and earlier, those variables are interpreted as being the same.
Like all versions of Flash Player, Flash Player 7 is backward-compatible: it plays SWFs that were published to earlier SWF formats. Case-sensitivity is enforced by Flash Player 7 only on SWFs published to the Flash Player 7 format. If you publish a SWF from Flash MX 2004 to Flash Player 6 format or earlier, Flash Player 7 doesn't enforce case-sensitivity on that SWF.
If you're careful about using consistent capitalization in your code, then this change shouldn't affect your scripts. However, some scripts that ran as expected in Flash Player 6 may not run the same in Flash Player 7 when published to the Flash Player 7 format.
Case-Sensitivity at Runtime and Compile-Time
ActionScript 2.0 enforces case-sensitivity at compile time. Depending on which version of ActionScript you are using, and what version of Flash Player you are publishing to, you may get different results at compile-time and runtime. Table 1 summarizes those differences.
| Table 1. Case-Sensitivity Differences at Runtime and Compile-Time | |
|---|---|
| Scenario | Case-Sensitivity Rules |
| Flash Player 7 ActionScript 1.0 or 2.0 |
When you publish files to Flash Player 7 or later, Flash implements case-sensitivity and usage of reserved words at compile-time and at runtime, whether you use ActionScript 1.0 or ActionScript 2.0. This means that keywords, class names, variables, method names, and so on are all case-sensitive. Variable names that differ only in capitalization are interpreted as being different variables. This change affects files loaded with #include and external variables loaded with LoadVars.load(). |
| Flash Player 6 ActionScript 2.0 |
When you specify ActionScript 2.0 and publish to Flash Player 6, case-sensitivity for variables used within classes (and reserved words) is checked at compile-time, even though runtime is case-insensitive. This means you could have two class member variables, foo and Foo, which the compiler allows you to define but which point to the same variable at runtime. Because of this, any functionality that depends on foo and Foo existing as separate variables could fail silently. |
| Flash Player 6 or earlier ActionScript 1.0 |
If you use ActionScript 1.0 and publish to Flash Player 6 or earlier, Flash works the same way as in Flash MX. Case-sensitivity for variables is not implemented. Variable names that differ only in case are considered the same and variable names cannot be the same as keywords even if they differ in case from the keyword. This same behavior exists in Flash MX today. |
Observing ActionScript 2.0 Reserved Words
ActionScript 2.0 introduces several new keywords that have special meaning to the ActionScript 2.0 compiler, including class, interface, extends, and several others. If you have a script that uses any of these reserved words, and are publishing to ActionScript 2.0, the compiler generates error messages. For a full list of ActionScript 2.0 keywords, see New Object-Oriented Programming Model in the ActionScript Reference Guide.
Components in Flash MX and Flash MX 2004
Macromedia introduced components in Flash MX as a way to help developers build user interfaces quickly. Flash MX 2004 debuts a new component architecture, called the version 2 (or v2) component architecture, that offers many features not available in the Flash MX component architecture (now called the version 1, or v1, architecture).
In addition, Flash MX 2004 ships with several more components than were shipped with Flash MX.
Differences Between Components in Flash MX and Flash MX 2004
If you programmed with the user interface components provided with Flash MX, you'll notice some changes in the v2 components. I discuss some of those changes below. For a full list of changes in v2 components, see What's New in v2 Components in the Using Components Guide.
New Component APIs and Event Model: Components you worked with before in Flash MX (for example, CheckBox or Button) expose a different set of properties and methods than you're used to. Because they inherit from (extend) the base classes of the v2 architecture (such as UIObject and UIComponent), the v2 components inherit the properties and methods provided by those classes.
The event handling model used by v2 components is also different than that used by v1 components. In Flash MX, you specified a "change handler" for a given component and then assigned a function to that change handler identifier:
// v1 change handler function:
componentHandler = function () {
// handle event here
}
Under the v2 component architecture in Flash MX 2004, you handle component events using event listeners, or component on() event handlers. You can't use the same kind of change handler code (as shown above) that you may have used when programming with Flash MX components.
Below is an example of using an event listener. It consists of two parts: a listener object that responds to an event and a component instance that registers the listener object to receive the event:
listenerObject.eventName = function(evtObj){
// your code here
};
componentInstance.addEventListener("eventName", listenerObject);
Event listeners provide a more flexible event handling model than change handlers in Flash MX. For example, a listener object can receive events from several components; likewise, a component can broadcast a single event to multiple listeners. For more information about handling component events, see About Component Events in the Using Components Guide.
More Components: Flash MX 2004 and Flash MX Professional 2004 include many new components and several new versions of components than were included in Flash MX.
Flash MX 2004 ships with 13 user interface components (compared to 7 in Flash MX). Flash MX Professional 2004 ships with the user interface components included with Flash MX 2004, in addition to several advanced user interface components, data components for working with external data sources, and media components for drag-and-drop video authoring.
Note that the TextArea component in Flash MX 2004 replaces the ScrollBar component in Flash MX; it also has a built-in scrolling feature.
Using Flash MX Components in MX 2004
Flash MX components are written in ActionScript 1.0, and Flash MX 2004 and Flash MX Professional 2004 components are written in ActionScript 2.0. Depending on what version of Flash Player you are publishing to and what version of ActionScript you use to create your content, components that you used in your Flash MX projects may or may not function as expected.
Table 2 summarizes the expected or potential results of using Flash MX components in Flash MX 2004, according to the Flash Player version you publish to and the ActionScript version you use. In general, we recommended that you not use the Flash MX components when publishing to Flash Player 7. Macromedia will soon be releasing a version of the Flash MX components that work in Flash MX 2004 and Flash Player 7. Availability of these components will be announced on macromedia.com as soon as they are ready.
| Table 2. Functionality of Flash MX UI Components Used in Flash MX 2004 | ||
|---|---|---|
| Publish Format | ActionScript Version | Result |
| Flash Player 7 | ActionScript 2.0 | Components not likely to function as expected |
| Flash Player 7 | ActionScript 1.0 | Components not likely to function as expected |
| Flash Player 6 | ActionScript 2.0 | Components possibly not to function as expected |
| Flash Player 6 | ActionScript 1.0 | Components to function as expected |
Compatibility of Flash MX 2004 Components with Earlier Flash Player Versions
All the components that ship with Flash MX 2004 work in Flash Player 6 or later. With a couple of exceptions, noted below, all components that ship with Flash MX Professional 2004 work in Flash Player 6 and later.
The following components (available in Flash Professional only) require Flash Player 7 or later:
- Media components (MediaController, MediaDisplay, MediaPlayback)
- DataSet component
You must use the ActionScript 2.0 compiler when publishing documents that use Flash MX 2004 components (see Publishing to ActionScript 2.0 and ActionScript 1.0 earlier in the article).
Combining Flash MX and Flash MX 2004 Components in a Single Project
You can combine Flash MX and Flash MX 2004 components in a single Flash document, as long as you observe the rules of compatibility with ActionScript and the Flash Player versions (as described in the previous section. However, many of the automated infrastructure features provided by Flash MX 2004, such as live preview, may not work under these circumstances.
DevNet Resource Kit Components in Flash MX 2004
The Flash components included in DevNet Resource Kit (DRK) Volume 1-4 were not designed to work with Flash MX 2004. If you install the components into Flash MX 2004, they may not function properly.
DRK Volume 5 includes updated versions of DRK Volumes 1-4 components that work in Flash MX 2004 and Flash Player 7. For more information, see DevNet Resource Kit Volume 5.
In addition, the functionality of many of the components from DRK Volumes 1-4 have been included in the components that ship with Flash MX 2004 and Flash MX Professional 2004. These new components include all the advanced capabilities of the v2 component architecture.
The component functionality included in Flash MX Professional 2004 includes the following:
- DevNet Resource Kit Volume 1: DataGrid, Media Components, Loading Box, Advanced Message Box
- DevNet Resource Kit Volume 2: Smart Combo Box, Advanced Calendar, Simple Menu
- DevNet Resource Kit Volume 3: Text Field
Video in Flash MX and Flash MX 2004
In Flash MX, you can add video to your Flash content in one of three ways: importing it into your Flash document, adding video frames to the Timeline, or using Flash Communication Server to stream video into your Flash content.
In addition to these techniques, Flash MX 2004 allows you to play external Flash Video (FLV) files from a local file system or an HTTP address. This approach offers several benefits, including the ability to play long video clips without affecting performance, play video at a different frame rate than the Flash document that contains it, among other pluses. This feature is available in Flash Player 7 and later.
Flash MX 2004 includes the Video Import wizard which greatly simplifies the process of using embedded video in your Flash applications and presentations. The Video Import wizard gives you the option of editing video before importing it. You can also apply customized compression settings, including bandwidth or quality settings, as well as advanced settings for color correction, cropping, and other options.
Video performance has been greatly improved in Flash Player 7. All video, regardless of how you use it in your Flash presentations and applications, looks better and runs faster and more smoothly than in previous versions of Flash Player.
Video Enhancements in Flash MX Professional
Both Flash and Flash Professional provide the ability to play FLV files from the local file system or an HTTP address. In the standard edition of Flash, you write custom ActionScript to play external FLV files. Flash MX Professional provides several authoring features that make it easier to add video to your Flash projects.
Media Components: Flash Professional includes several media components that allow you play video or audio easily through progressive download, or stream using Flash Communication Server. These include MediaController, MediaDisplay, and MediaPlayback. These media components also let you add cue points to FLV video clips that trigger custom ActionScript commands.
FLV Exporter: Flash Professional ships with the FLV Export plug-in that lets you export FLV files directly from any video editing application or batch-encoding tool that supports the QuickTime Plug-in Architecture. For a complete list of supported video editing tools, as well as details on using the FLV exporter, see Exporting FLV Files from Video-Editing Applications in the Using Flash Guide.
Video in Flash Communication Server MX and Flash MX 2004
Both Flash Communication Server MX and Flash MX 2004 support playback of the FLV video format, which allows you to deliver truly unique, interactive video experiences. The differences between the two products, however, lie in how they deliver one-way video and in the additional multiway capabilities found in Flash Communication Server.
One-way web-based video authored with Flash MX 2004 is delivered to users using progressive download, whereas Flash Communication Server streams video to the end user (see the next section). In addition, Flash Communication Server provides video capture, live video streaming, multiway/multiuser video capabilities, and programmable stream control, which allow developers to create interactive audio/video applications.
Flash Communication Server MX 1.5 works with all the media components in Flash MX Professional 2004. The Flash Communication Server MX 1.5 authoring components (for example, SimpleConnect and AudioConference) work in Flash MX 2004 as long as you publish to the Flash Player 6 format. Macromedia is updating the authoring components and tools for use in Flash MX 2004. When they're available, you can get this update from the Flash Communication Server product page.
Streaming Versus Progressive Download
As I mentioned, one-way web-based video authored with Flash Professional 2004 is delivered to users using progressive download, whereas Flash Communication Server streams video to the end user.
Progressive download is a method of video delivery in which a video file starts to play, after a short buffer period, while it is being downloaded to the client's computer. It's easy to deploy video in this manner because it requires nothing more than a web server. It also provides a good experience (especially with short videos that don't need long buffering times). Because the video is downloaded to the client's computer, it allows the end user to rewatch the video without having to download it again.
Streaming video, by contrast, sends video in real time to a client machine, which plays the video as it is received and then discards it. A streaming server such as Macromedia Flash Communication Server MX can establish an intelligent connection with the client to allow the video to respond to the network connection and client requests. Because streamed video starts fast, plays in real time, and allows users to access different parts of the video immediately without first downloading the entire the video file beforehand, it's a great solution for long-playing videos, live video broadcasts, and applications that interact extensively with users.
In addition, streamed video optimizes video delivery to a large number of clients because it delivers video just as it is needed; progressive downloaded video, on the other hand, delivers video as fast as a user's computer accepts it. For large sites, streamed video reduces the overall load on servers.
Table 3 summarizes the differences between video delivered by streaming and progressive download. Think of the new video features in Flash Professional as an intermediate solution between importing video into your Flash file and streaming video using Flash Communication Server.
| Table 3. Benefit Comparison of Streaming vs. Progressive Downloading | ||
|---|---|---|
| Benefit | Streaming | Progressive |
| Live broadcasts | X | |
| Fast start | X | |
| Long clips | X | |
| Immediate random access to different parts of a movie | X | |
| No specialized server | X | |
| Consistent high-quality playback at any connection speed | X | |
| Content downloads to client machine | X | |
| Content remains on server (cannot be saved by viewers) | X | |
Data Integration in Flash MX and Flash MX 2004
Flash MX provides several ways to interact with external data sources, including loading and parsing XML, implementing Macromedia Flash Remoting MX technology, and socket connectivity.
In addition to these methods and techniques, Flash MX Professional 2004 offers a complete framework for data integration in your Flash applications. This framework consists of four layers: data connectivity, data management, data resolution, and data binding.
- The data connectivity layer sends and receives data from a variety of external data sources, such as web services and XML. This layer is implemented by "connector" components, including WebServiceConnector and XMLConnector.
- The data management layer sorts, filters, and searches data, as well as tracks changes made to data. The functionality of this layer is provided by the DataSet component.
- The data resolution layer encodes and decodes delta packets (which are changes made to data by the Flash client or the data source server). Delta packets are transmitted over the data connectivity layer in a format that both the external data source and Flash client can consume. This layer is implemented by the data resolver components, including RDBMSResolver and XUpdateResolver.
- The data binding layer binds external data easily to user interface components, either visually in the authoring environment or at runtime using custom ActionScript.
For more information about data integration in Flash Professional, see the Data Integration Overview on the Macromedia Flash Developer Center.
Flash Remoting is just as important as it has ever been to Macromedia customers, and Macromedia continues to sell and support Flash Remoting. Therefore, you can continue to use Flash Remoting in your applications. You can also integrate Flash Remoting with the new data management features in Flash Professional.
The Flash Remoting client-side components and tools have been updated to work in Flash MX 2004. You can download them from the Macromedia Flash Remoting MX Components page.
Using Flash Remoting with Data Components
You can continue to use Flash Remoting as you have in previous versions of Flash. You also have the option of leveraging the data management features provided by the DataSet component to manage recordsets returned by a Flash Remoting service method call. The DataSet component gives you greater control over your Flash Remoting data by making it easier to manipulate data, track changes made to data, and update the server.
The DataSet component exposes a dataProvider property, to which you can assign any object that implements the DataProvider API. This includes recordsets returned by Flash Remoting. For example, suppose you create an instance of the DataSet component named remoting_ds. The following code assigns the results of a Flash Remoting method call named getUsers() to the DataSet object's dataProvider property:
function getUsers_Result(results){
remoting_ds.dataProvider = results;
}
You can also assign Flash Remoting recordsets directly to any component that provides a DataProvider interface, such as the DataGrid or List components.
Loading Data Across Domains
In previous versions of Flash Player a SWF that originated from one domain (for example, www.mysite.com) could load data from any server located in its same subdomain (for example, data.mysite.com). In other words, you could load data across similar domains.
In Flash Player 7 the domain of the SWF and the external data source must match exactly, otherwise the data loading call fails. For example, by default, a SWF that is loaded from www.mysite.com can only load data located at www.mysite.com.
To permit data loading across different domains, you must create a security policy file and place it on your server. A policy file indicates what domains are permitted to access data on that server. Any SWF that originates from a permitted domain can load data from that server.
For more detailed information about the new security features in Flash Player, see Deneb Meketa's article, "Security Changes in Macromedia Flash Player 7."
Authoring Environment Changes in Flash MX 2004
Macromedia Flash MX 2004 unveils several new authoring features, including an integrated Help panel, a Behaviors panel for easily adding scripts, and a History panel. Here's how these changes improve or affect your workflow.
Writing Scripts
Flash MX 2004 introduces several changes and enhancements to how you add ActionScript to Flash documents.
Normal Mode and the Behaviors Panel: In previous versions of Flash the Actions panel provided two scripting modes: Expert and Normal. Normal scripting mode helped designers and novice ActionScript programmers add interactivity easily to their animations and presentations. By contrast, Expert scripting mode was intended more for advanced programmers who wrote customized and complex scripts.
In Flash MX 2004 the Actions panel no longer features Normal scripting mode. What was called Expert scripting mode is now the default (and only) mode for writing scripts in the Actions panel.
To replace the features provided by Normal scripting mode, Flash MX 2004 now has the Behaviors panel, which lets you easily add common ActionScript functionality, such as frame navigation, loading of external SWFs and JPEGs, controlling stacking order of movie clips, and movie clip dragging functionality. You can also use the Actions panel to modify (or learn from) the code created by the Behaviors panel.
Script Window: Flash Professional includes a built-in ActionScript editor, called the Script window, which lets you create external ActionScript (AS) files easily without leaving the Flash authoring environment. The Script window has the same features as the Actions panel you use to add scripts to FLA files, such as the Actions toolbox, code hinting, autoformatting, and syntax-checking.
Reorganized Actions Panel Categories: The Actions panel categories in Flash MX 2004 have been reorganized to reflect the ActionScript language structure better and to make the language more approachable and learnable for programmers new to ActionScript (see Figure 2).
Figure 2. The Actions toolbox
Invoking Code Hints: In previous versions of Flash, to trigger code hints—pop-up menus that list possible method or property names for a given data type—you need to end all variable names with specific suffixes. For example, the default suffix is "_mc" for movie clip objects and "_xml" for XML documents.
This feature is still supported in Flash MX 2004 but now you can invoke code hints for a variable by strictly typing that variable using colon (:) syntax. For example, suppose you type the following:
var names:Array = new Array(); names.
As soon as you type the period (.), Flash displays a list of methods and properties available for Array objects because you typed the variable as an array. For more information on strict data typing, see the section "Strict Data Typing in ActionScript 2.0" earlier in this article.
Getting Help
The Reference panel in Flash MX provides detailed descriptions of functions, statements, and objects listed in the Actions toolbox. In addition, the entire Flash help system appears in an online format viewable in a web browser.
In Flash MX 2004 the Reference panel and online HTML help system are removed; their features now appear in a single location: the Help panel (see Figure 3). To access the Help panel, choose Help > Help.
The Help panel provides enhanced functionality not available in previous Flash help systems:
- Auto-update feature: Download updates to the Flash help system as they become available.
- Integrated tutorials and lessons: Because the Help panel is part of the Flash environment, you can complete Flash lessons and tutorials without switching back and forth between the web browser and the authoring tool.
- Improved search functionality: Search the Flash documentation more easily and display the results in a collapsible tree view.
Figure 3. Help panel in Flash MX 2004
Changes to "Undo" and the History Panel
The Undo feature (Edit > Undo) in previous versions of Flash was object-specific: There was a separate set of undo steps for different objects, such as the Stage, movie clips, and library. In Flash MX 2004, the undo stack is now document-specific.
The History panel in Flash MX 2004 shows a list of the steps you've performed in the active document since you created or opened that document, up to a specified maximum number of steps.
The History panel offers many powerful authoring features not available in previous versions of Flash, including the following:
- Undoing or redoing individual or multiple steps at once
- Applying steps in the History panel to the same object or to a different object in the document
- Creating commands from several steps and running them from the Commands menu
Screens in Flash MX Professional 2004
Flash developers and designers have often used frames in the Timeline to define application "states," or slides, in a linear presentation. While this authoring technique may be familiar to experienced Flash developers, it can make creating and maintaining complex applications difficult—for experienced and new users alike.
Screens in Flash MX Professional 2004 provide high-level containers for creating applications. With screens, you can structure complex applications in Flash without using multiple frames and layers on the main Timeline. In fact, you can create a complex application without viewing the main Timeline at all.
Create screen-based documents of two different types: a Flash slide presentation suitable for sequential content (such as a slide show or multimedia presentation) or a Flash form application ideal for nonlinear, form-based applications, including Rich Internet Applications.
When you work with a screen-based document, the Screen Outline pane at the left of the Document window displays thumbnails of each screen in the current document in a collapsible tree view (see Figure 4). The tree represents the structural hierarchy of the document. Nested screens are indented below the screen that contains them.
Figure 4. Example of a form application
The screenshot above illustrates a form application built with screens. In this case, the application uses three forms to contain each of three application states: a login form (shown below), a shopping cart form, and a check out form.
Using ActionScript and Behaviors with Screens
Screens are similar to nested movie clips in the way they interact with ActionScript. (See Nested Movie Clips in the Using Flash Guide.) When you select a screen in the Screen Outline pane and add ActionScript, the script is added directly to the screen as an object action (much as ActionScript is added directly to a movie clip). It's usually best to use object actions for simple code (such as creating navigation between screens) and external AS files for more complex code.
Extending the Form and Slide Classes
Forms and slides—the two types of screens in Flash Professional—are represented at runtime by the Form class (mx.screens.Form) and Slide class (mx.screens.Slide), respectively. The runtime class associated with a form or slide is determined by the Class Name setting in the Property inspector (see Figure 5)
Figure 5. Determining the Class Name setting in the Property inspector
By default, mx.screens.Form is the class assigned to form objects and mx.screens.Slide is the class assigned for slide objects. However, you can also extend (create a subclass of) the Form or Slide class and assign your custom class using the Property inspector.
Extending the core screen classes is recommended when you create a complex application or presentation where individual forms or slides require customized behavior or functionality.
Flash Player 7 Enhancements and Changes
Flash Player 7 provides several new runtime features and improvements to Flash Player 6. Several new features offer functionality not available in previous versions of Flash Player (such as text style sheets); others provide improved methods and techniques for achieving what was possible before (improved print handling, for instance).
Table 4 lists some of the new ActionScript features in Flash Player 7. For a full list of changes in Flash Player 7, see New and Changed ActionScript Language Elements in the ActionScript Reference Guide.
| Table 4. Partial List of New Features in Flash Player 7 | |
|---|---|
| Feature | Description |
| Custom context menus | Runtime control over the Flash Player context menu. For more information, see the entries for ContextMenu and ContextMenuItem in the ActionScript Reference Guide. |
| Text style sheets | Apply CSS styles to HTML- or XML-formatted text at runtime. For more information, see Formatting Text with Cascading Style Sheets in the ActionScript Reference Guide. |
| Embedded images in text fields | Embed external JPEGs, SWFs, or movie clips inside text fields. See Embedding Images, SWF Files, and Movie Clips in Text Fields in the ActionScript Reference Guide. |
| Enhanced print handling | The ActionScript PrintJob class improves upon the print() and printAsBitmap() functions by adding the ability to print dynamically rendered pages as a single print job, as well providing access to the user's printer settings. See Using the ActionScript PrintJob Class in the ActionScript Reference Guide. |
| New movie clip preloading mechanism | The MovieClipLoader class provides a powerful and simple way to track the download progress of external SWFs and JPEGs. See Preloading SWF and JPEG Files in the ActionScript Reference Guide. |