ActionScript 2.0 Overview - Changes to ActionScript 1.0 in Flash Player 7
(Page 7 of 7 )
In a Flash Player 7–format .swf file running in Flash Player 7, some ActionScript 1.0 code behaves differently than it does in Flash Player 6. These changes bring Flash Player 7 closer to full ECMAScript 3 compliance. Specifically:
- The value undefined converts to the number NaN when used in a numeric context and to the string “undefined” when used in a string context (in Flash Player 6, undefined converts to the number 0 and to the empty string, “”).
- Any nonempty string converts to the Boolean value true when used in a Boolean context (in Flash Player 6, a string converts to true only if it can be converted to a valid nonzero number; otherwise, it converts to false).
- Identifiers (function names, variable names, property names, etc.) are case sensitive. For example, the identifiers firstName and firstname refer to two different variables in Flash Player 7. In Flash Player 6, the identifiers would refer to a single variable. (However, as usual, frame labels and symbol linkage IDs are not case sensitive.)
The preceding changes affect you only when you are updating a Flash Player 6–format movie to a Flash Player 7–format movie in order to use a feature unique to Flash Player
7. That is, if you upgrade your movie, you must test and possibly modify your code to make sure that it operates the same in Flash Player 7 format as it did in Flash Player 6 format. If you do not need Flash Player 7 features in your movie, you can continue to export it to Flash Player 6 format and it will usually run in Flash Player 7 exactly as it did in Flash Player 6. This last point cannot be emphasized enough.
Macromedia goes to great lengths to ensure that movies exported in older versions of the .swf format, such as Flash Player 6 format, continue to operate unchanged even if played in a later Player, such as Flash Player 7. However, when you publish a movie in Flash Player 7 format, you must be mindful of the changes implemented since the previous version of the .swf format. That is, the changes needed in your ActionScript depend on the .swf file version, not the Flash Player version.
Of course, any newly created .swf files exported in Flash Player 7 format (and not just those upgraded from Flash Player 6–format .swf files) must obey the new conventions, so keep them in mind moving forward. Remember that these new conventions bring ActionScript in line with other languages such as JavaScript and Java, making it easier to port code to or from other languages.
Flash 4 Slash Syntax Is Not Supported in ActionScript 2.0 In Flash 4 and subsequent versions, variables could be referenced with so-called “slash syntax.” For example, in Flash 4, the following code is a reference to the variable x on the movie clip ball:
/ball:x
That syntax generates the following error if you attempt to use it with the Action-Script 2.0 compiler, whether exporting in Flash Player 6 or Flash Player 7 format:
Unexpected '/' encountered
Let’s Go OOP Now that we’ve had a taste of what ActionScript 2.0 has to offer, we can start our study of object-oriented programming with Flash in earnest. When you’re ready to get your hands dirty, move on to Chapter 2!
 | If you've enjoyed what you've seen here, or to get more information, click on the "Buy the book!" graphic. Pick up a copy today!
Visit the O'Reilly Network http://www.oreillynet.com for more online content. |
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |