|
Flash 5.0 Tips Working With the New ActionScript Expert and Normal Mode The new Actions panel sports a flexible design to fit the needs of coders and designers. For coders comfortable working with script in a freeform environment, the Expert mode displays the Actions panel as a simple word processor. For beginners or Flash 4.0 users who prefer the old interface, Normal mode provides a more rigid environment for scripting.
You can set the Actions panel mode in detail, varying from object to object, or you can set a global preference. Click the Edit menu and select Preferences. The Preferences dialog box appears, and at the bottom of the General tab, you can choose either Normal mode or Expert mode as the Actions panel default.
Color Coding ActionScript now more closely resembles JavaScript than its Flash 4.0 version, and the added complexity warrants the need for usability improvements. The new color-coding feature in the Actions panel makes it easier to write, read, and troubleshoot scripts.
To turn on the color-coding, open the Actions panel. Click the Reveal menu and select Colored Syntax if it is unchecked. The colors will be displayed in both Normal and Expert modes.
External Script Files Flash 5.0 responds to the need for more collaboration and workgroup support. Especially frustrating in script-heavy projects, the single-user construction of Flash 4.0 caused bottlenecks when programmers and designers needed to work on the same file. In Flash 5.0, the ActionScript #include directive tackles the problem, letting you store scripts in external text files that are drawn upon during export. Programmers can now edit the script files independently while animators or artists work on the FLA file.
To use an external script file, select the frame or object you want to add the script to, open the Actions panel, and type in the existing script:
#include "filename.as"
Never end the line with the evaluate (;) operator, because it yields an error. You can name your text files anything you like, but .as is the recommended extension and denotes that the file contains ActionScript code.
Learning the New Dot Syntax Up to version 4.0, Flash used a particular form of notation known as Slash Syntax. Slash Syntax closely resembles the system of notation used in URLs and the Unix or Windows file systems. Flash 5.0 ActionScript ditches Slash Syntax in favor of Dot Syntax, matching the standardized system used in Java and JavaScript.
To come to grips with the new way of writing scripts, here is a sample conversion table:
The Old Way What It Means The New Way / The main timeline in the current level _root ObjectA/:MyVariable A variable attached to a particular timeline ObjectA.MyVariable GetProperty("ObjectA","Height") Reading the property of an object ObjectA._height /ObjectA/ObjectB An absolute object path _root.ObjectA.ObjectB ../ObjectA/ObjectB A relative object path _parent.ObjectA.ObjectB Tell Target("ObjectA") Play End Tell Target Invoking Movie Clip methods ObjectA.play()
As you can see, the new language bears little resemblance to previous versions. Once you get the hang of the new system, you'll find that it's more direct and simple to use.
|