|
Free Open Book
Macromedia Flash 8 Bible |
The Basic Context for Programming in FlashWith the enhanced Actions panel (also known as the ActionScript editor) in Flash 8, you can program interactivity by writing interactive commands directly into the Script pane of the Actions panel.
In the Actions panel, you can type your code from scratch, as well as insert your code with the help of Action booklets or the new Script Assist feature. Syntactically, ActionScript looks and feels very much like JavaScript. Macromedia has gone to great lengths to make ActionScript compatible with ECMAScript 4 (the standard programming guidelines derived from JavaScript). And like other object-oriented languages, ActionScript is composed of many familiar building blocks: variables, operators, conditionals, loops, expressions, built-in properties, subroutines, and native functions. Accessing ActionScript CommandsAll of the ActionScript commands are found in the Flash interface in the Action booklets or plus (+) button menu of the Actions panel. However, assembling actions with one another is not something Flash 8 automatically performs unless you use the Behaviors panel to add interactive functionality to your movie elements. Although it is beyond the scope of this chapter to fully explain fundamental programming principles, we can give you a sense of the whole of ActionScript by providing an organized reference to each of its parts. Actions List Organization in the Actions PanelIn the Actions panel, you can cut, copy, and paste code within the Script pane from one area of your movie to another using Ctrl+X (z+X), Ctrl+C (z+C), and Ctrl+V (z+V), respectively. You are free to select partial or entire lines of code, and modify the code in any way you want. With Flash 8, you can even edit your code in your preferred text editor! If you want to create your own programming macros in other programming applications, you can write your scripts outside of the Flash authoring environment and copy the final code into the Actions panel when you're done.
The Help PanelDon't know what the methods of the Sound object are? Need to see if the getVersion() function will work in a Flash Player 4-compatible movie? Flash 8 has conveniently nested everything related to help documentation in the Help panel. Among other items, the new Help panel contains all the syntax of the ActionScript language. You can access the Help panel in a few ways:
We'll quickly show you how to use the new Help panel in an actual Flash document:
You can select other actions from the left pane of the Help panel and view their descriptions.
ActionScript 1.0 and 2.0So why all the fuss about ActionScript now? Let's make one thing clear right away: For most Flash designers and developers, or rather for most of the work that's done in Flash, the graduation of ActionScript 1.0 to 2.0 may mean next to nothing at all. This isn't to say that ActionScript 2.0 should be ignored or is not a monumental leap forward for Flash programming — we simply want to calm or allay any fears you might have after reading about ActionScript 2.0 from other sources. If you've used ActionScript in Flash versions prior to MX 2004, then ActionScript 1.0 refers to the coding styles that those versions of the application used. ActionScript 2.0 introduces a couple of major structural changes to the way in which you can code Flash ActionScript. To begin with, it uses strong data typing. You'll learn more about data typing in Chapter 26, "Using Functions and Arrays," but for now, know that ActionScript 2.0 imposes some rules on how you can assign values to variables, functions, and other objects in your code. Unless you're creating code that uses custom classes and object-oriented programming concepts such as inheritance and prototypes, you won't really need to worry about whether your code will work as ActionScript 2.0 code. Another big change with ActionScript 2.0 is case-sensitivity. Prior to Flash Player 7, most ActionScript terms were case-insensitive, meaning you could refer to object references or variables with varying cases, such as: var firstName = "Robert"; var lastName = "Reinhardt"; var fullName = firstName + " "+ lastName; In ActionScript 1.0, you could have used the following code as the last line, without receiving an error: var fullName = firstname + " "+ lastname; However, in ActionScript 2.0, that same line of code would be incorrect because firstname and lastname are not using the same case as the original variables. Why should the distinction between ActionScript 1.0 and 2.0 even be an issue? For starters, when you publish a Flash movie for Flash Player 6, 7, or 8, you need to decide how Flash 8 will compile the ActionScript code in your document. In the Publish Settings dialog box, you can choose which ActionScript version to publish in the Flash tab. Unless directed otherwise, you'll publish most of the Flash movies for Part VII of this book as ActionScript 2.0, even though it pretty much looks and feels like ActionScript 1.0. |
Main Menu |
| 500 Juegos Gratis | 500 Giochi Gratis | 500 Jeux Gratuits | 500 Jogos Gratis | 500 Kostenlose Spiele |