ActionScript 3 Syntax preview

Posted October 11, 2005 12:47 pm
Filed under: AS3, ActionScript, Articles by Paul, Flash, Opinions

Update: Alas, I knew this would be short-lived in value when I posted it. =) Now that ActionScript 3 information has been released by Macromedia, you’ll find these links to ActionScript 3 language descriptions and differences from AS2 more useful than this preview based on the ECMAScript proposal.

I have to admit, since I first heard details about ActionScript 3, combined with the details of Flex Builder 2 (finally Flex the way I wish it was from v.1) I have been jumpy with excitement to tell people about what’s coming: coworkers, users’ group members, and even my wife has gotten an earful. I definitely consider this to be the best thing to happen yet in ActionScript development. (Maybe I should have applied for that Flex Technical Evangelist position, since that’s what I find myself wanting to do anyway!)

So, being unable to wait I dug up the ECMAScript (ECMA-262) 4th edition proposal and combed through it to find out what I could about what’s coming in ActionScript 3. Obviously Macromedia can choose what things to implement or not implement, but they have said (I’m paraphrasing here) that their goal is to be as close to the spec as they can, even the target implementation of the spec. So I think by looking at the spec we can get a pretty good idea at least from the syntax point of view what ActionScript 3 will be like. Of course, the object model is another story — for that we’ll just have to wait to see what Macromedia gives us, and what we as a developer community do with it!

So here’s my summary of the things in the ECMAScript 4th edition proposal which are not included in ActionScript 2. If you are a Macromedia employee, feel free to skip to the end to read other things that I would like to see implemented in addition to what’s in the spec.

Note: in addition to the things included here, Macromedia has publicly stated that AS3 will also support DOM Level 3 events and E4X, which are different specs (E4X is specifically an extension to ECMAScript).

Disclaimer: This is obviously just my interpretation of the ECMAScript spec; it is very possible that I missed or misinterpreted something, so this information may not be correct. In addition, Macromedia has the option of choosing to implement or not implement portions of the spec at their pleasure. Having said that, if you believe a correction is in order, please leave a comment or contact me.

Keywords

Operators

Scope

The following statements now have their own local scope:

Note: a variable will be "hoisted" (it will follow the scope rules of ECMAScript 3/AS2) when all of the following are true: it is defined in a var statement; the definition doesn’t specify a type; it has no attributes except true; the scope it would be hoisted into is not a class; Strict mode is not being used.

Strict mode

This is a more strict compile-time type checking mode. The following conditions are imposed by Strict mode:

Attributes (modifiers)

Variables are public final by default; methods are public virtual by default.

Variables

Method (function) parameters

Classes

Packages

Namespaces

This provides a mechanism to define certain portions of a code file — for example, certain methods of a class — as belonging to one or more namespaces. The use case presented in the spec is to provide a mechanism for creating multiple versions of code in a single file. You could define multiple versions of a method or property, or add new methods and flag them as only belonging to a certain version. Other code which refers to that code can specify which namespace (i.e. which version) of the code it is defined to use, and only the parts of the code which are flagged as belonging to that version (namespace) will be compiled.

I can see how this would be useful for the "importing other authors’ code from a url" situation — if the author updates the code, he/she can specify versions in the same file, and as long as your code points to the version it was created to work with, your code will never break. For ActionScript I don’t know if this is as useful — although I suppose this would allow authors (e.g. Macromedia) to create new versions of classes and still provide a single source file, and would avert the need for separate classpath folders like Macromedia had to do with Flash 8.

Predefined types

* Types marked with an asterisk were defined in ECMAScript 3 but not included in ActionScript 2

There is no longer a distinction between objects and primitive types (all types are objects).

String(), Integer(), Number() are now explicit coercions rather than type conversion functions.

Machine types

These are types defined in the spec, but their names are not reserved words and can be used as identifiers.

Numeric literal suffixes: To specify a literal number of certain types, you need to add a suffix to the number (e.g. var x:long = 25L;). The suffixes are l or L for long; ul, uL, Ul, or UL for ulong; f or F for float.

Things I would like to see, which aren’t in the spec

Macromedia, please take note! You said you wanted to get developer feedback on the direction of ActionScript 3; well, here’s my first feedback:

Things I wish were added, but aren’t (at least, not in the standard)

Things included in AS2 but not in ECMAScript 4th edition

I expect Macromedia will keep these things around in ActionScript 3, and hopefully even add a few more nice things too!

You can leave a comment, or trackback from your own site.

31 Comments so far


  1. Peter Elst » What AS3 might look like … is reported to have said:

    […] like …

    Posted by Peter on October 11th 2005 to Flash
    Paul Robertson takes a detailed look at the ECMAScript 4 proposal which should giv […]


  2. binaryatwork is reported to have said:

    AS3 seems better than AS2.

    However, there are still a few things in my wish list
    1) real protected functions
    2) pure abstract functions
    3) better exception handling. AS2 does not throw exception at all and it is a nightmare to debug it.
    4)


  3. Ryan is reported to have said:

    Thanks for taking the time to go through the spec and write such an informative article. I second the need for method overloading, having methods with multiple return types is hot. The rest looks great too! I guess it’s up to the lads to decide though.


  4. Alan Shaw is reported to have said:

    Let’s get started! Counting the days…

    Totally agree about protected and operator overloading, especially +, -, +=, -=, *, *=, /, /=. Vector math!


  5. JanuMedia :: ActionScript 3.0 Syntax :: October :: 2005 is reported to have said:

    […] 12, 2005 5:21 am ActionScript 3.0 Syntax Paul Robertson give us the the ActionScript 3.0 syntax preview. He looked details […]


  6. Joan | Garnet is reported to have said:

    Primeras hipótesis acerca de AS3.0

    Paul Robertson hace un repaso a lo que ActionScript 3.0 va a ser (o puede que sea). En el artículo se revisa el estado actual de ActionScript (AS2.0) y se hace una comparación con ECMAScript 4, que es a lo…


  7. ai829 is reported to have said:

    cool~~~~”package” is my fovar favorite


  8. Tek is reported to have said:

    I don’t see any mention in the ECMA 262-4 proposal to the possibility to create classes into classes. It is really something I want to be integrated in Flash because of the behavior of the compiler that understands only one class by file. It is a real pain to create a class file to declare a simple object with only variables in it for example.


  9. Paul Robertson is reported to have said:

    @binaryatwork:
    On your #3, I’m hopeful that, assuming they include all the predefined error types, the built-in classes will actually throw errors rather than just ignore them. Parts of the ECMAScript spec do define that under certain conditions certain errors should be raised. Also, in at least a couple of the MM articles about AS3 I think they’ve mentioned that both compile-time and runtime errors will be improved. (Fingers crossed).

    @Tek:
    Look above at the section titled “Classes”. The first item says this:
    “[you] can have inner classes (classes declared inside of other classes) — these must be declared static.”

    I think that’s what you’re saying you want, right?

    On a separate but related note, if MM implements the package statement, it should theoretically be possible to define multiple classes (not nested) inside a single class file, and wouldn’t need to require that the folder structure match the package names. (Although admittedly with my C# code I avoid files with multiple classes and do make the folder structure match the code structure). I can see where those things would be particularly useful with a JavaScript library that was being loaded by a web browser — maybe they are not so necessary for AS.


  10. Pavel Simek is reported to have said:

    I expect the “intrinsic” modifier no more being needed (except for just the built-in player API), since the new AS3 bytecode should contain all the type-checking and other information used by the compiler… What do you think? Are we going to include SWF/SWC directly into the classpath instead of intrinsic class files?


  11. cogniblog » ActionScript3.0 Info is reported to have said:

    […] ctober 14th, 2005 at 1:35 pm (actionscript) I just stumbled upon this great article by Paul Robertson reviewing the changes in the upcoming (spring) rel […]


  12. Luca Deltodesco is reported to have said:

    I deffinately agree for overloading, its such a pain with vector math or complex math or any such to have to use functions instead of operators


  13. ActionScript is reported to have said:

    links from TechnoratiActionScript 3 Syntax preview


  14. ActionScript is reported to have said:

    links from TechnoratiActionScript 3 Syntax preview


  15. ActionScript is reported to have said:

    links from TechnoratiActionScript 3 Syntax preview


  16. Flashbattle.de Forum | ActionScript 3.0 | [ActionScript 3.0] ActionScript 3.0 (Linksammlung) is reported to have said:

    Kramer auto Pingback[…]        In der folgenden Linksammlung werden wir nützliche Hyperlinks zum Thema ActionScript 3.0 und Flash 8.5 für Euch zusammentragen. Macromedia Adobe Labs - Technologie Labor von Adobe ActionScript 3.0 - Themensammlung ActionScript 2.0 zu ActionScript 3.0 - Migration Macromedia Flex 2.0 MXML und ActionScript Sprachreferenz ActionScript 3.0 - Fehlermeldungen und Warnungen (Codes) ActionScript 3.0 - Übersicht und Spezifikationen ActionScript 3.0 Wiki ActionScript 3.0 - Lernhilfen ActionScript 3.0 - Spezifikation Flash Professional 9 (Preview) ActionScript 3 - Resoureces APIs Libraries Adobe OpenSource Andere ActionScript 3.0 Linksammlung von Franto ActionScript 3.0 - Syntax preview ActionScript 3.0 - Error checking ActionScript 3.0 (Klassenposter) Liebe Grüsse Matze K. __________________[Flashstar] Flashstar Site [ActionScript - Praxis] ActionScript Praxis - Buchinfo [Flash 8 - HotStuff Buch] Bestellung [Flash 8 - Professional Series Buch] Bestellung [ActionScript Studienausgabe 2005] Bestellung […]


  17. ActionScript & Flash Praxis :: Thema anzeigen - ActionScript 3.0 (Linksammlung) is reported to have said:

    Kramer auto Pingback[…] In der folgenden Linksammlung werden wir n�tzliche Hyperlinks zum Thema ActionScript 3.0 und Flash 8.5 f�r Euch zusammentragen. Macromedia Adobe Labs - Technologie Labor von Adobe ActionScript 3.0 - Themensammlung ActionScript 2.0 zu ActionScript 3.0 - Migration Macromedia Flex 2.0 MXML und ActionScript Sprachreferenz ActionScript 3.0 - Fehlermeldungen und Warnungen (Codes) ActionScript 3.0 - �bersicht und Spezifikationen ActionScript 3.0 Wiki Adobe OpenSource Blog’s ActionScript 3.0 - Beitr�ge von Andr� Michelle ActionScript 3.0 - Beitr�ge von Bokel Andere ActionScript 3.0 Linksammlung von Franto ActionScript 3.0 - Syntax preview ActionScript 3.0 - Error checking ActionScript 3.0 (Klassenposter) Liebe Gr�sse Matze K. […]


  18. AS 3 und Flash Player 8.5 - Flashforum is reported to have said:

    Kramer auto Pingback[…] groe nderung bevor. Here it comes ActionScript 3 und Flash Player 8.5 Whats up with 3.0 http://probertson.com/articles/2005/…ma262_not_as2/ Hier ein interessanter Blog zum Thema Flash Player 8.5 […]


  19. NeoFlashers :: Ver tema - Action Script 3.0 FAAnswers is reported to have said:

    Kramer auto Pingback[…] http://labs.macromedia.com/wiki/index.php/ActionScript_3 http://probertson.com/articles/2005/10/11/as3_ecma262_not_as2/ Saludos!!_________________FLASH BLOG==> […]


  20. ActionScript & Flash Praxis :: Thema anzeigen - ActionScript 3.0 (Linksammlung) is reported to have said:

    Kramer auto Pingback[…] Michelle ActionScript 3.0 - Beitrge von Bokel Andere ActionScript 3.0 Linksammlung von Franto ActionScript 3.0 - Syntax preview ActionScript 3.0 - Error checking ActionScript 3.0 (Klassenposter) Liebe Grsse Matze […]


  21. 無聊文章~~ is reported to have said:

    […] 2.0其實推出不算很久,相信很多人還在摸索中,但Action Script 3.0已慢慢出來了. ActionScript 3 Syntax preview 其實之前我已覺得寫Action Script 最難之處, […]


  22. www.gotoandplay.it :: View topic - - ActionScript 3 Syntax preview - is reported to have said:

    Kramer auto Pingback[…] but probably pretty close to what the real thing’s gonna look like, just check it for yourself http://probertson.com/articles/2005/10/11/as3_ecma262_not_as2/ boldergeizd_________________http://boldergeizd.blogspot.com/ What I see Is What You […]


  23. egoldy flashblog » Actionscript 3 ﷨ is reported to have said:

    Kramer auto Pingback[…] 3 ﷨Ԥ,˵Actionscript 3 ﷨ģ ActionScript 3 Syntax preview (1880 […]


  24. Actionsript 3.0 - Tanya@Putera is reported to have said:

    Kramer auto Pingback[…] more info on AS3.0 example AS3.0 syntax ok guud luck with it..wassalam.. […]


  25. Shaun is reported to have said:

    Hi there. This is an interesting article. I hate that operator overloading wasn’t introduced. It’s great for custom maths classes. Also, method overloading would’ve been nice for tidying things up a little. A bit annoying that these weren’t added.

    It’s definitely an improvement on AS2, though, in terms of what it offers to us C/C++ immigrants.


  26. NG BBS — Flash Player 9, Flash 9 Beta is reported to have said:

    Kramer auto Pingback[…] http://probertson.co..as3_ecma262_not_as2/ […]


  27. Flash 9 - BLAZE Announced - Page 2 - Ultrashock Forums is reported to have said:

    Kramer auto Pingback[…] posted by BadSanta Yeh, got this link from Peter Elst’s blog. Good summary of what to expect. http://probertson.com/articles/2005/…ma262_not_as2/ oh no another rocket! is everyone forgetting how bad this sucked… […]


  28. ռflashվַ........... - վ - վ̳ - վ֮,վԴ,ݸվ,վ,վ,վ,վ,վ̳йվһɳ is reported to have said:

    Kramer auto Pingback[…] http://livedocs.macromedia.com/specs/actionscript/3/wwhelp/wwhimpl/js/html/wwhelp.htm as3﷨ http://probertson.com/articles/2005/10/11/as3_ecma262_not_as2/ as3ļصַ  شļ AS3XML  http://www2.flash8.net/teach/5462.htm […]


  29. FlashDevelop.org - View topic - Add "virtual" keyword support. is reported to have said:

    Kramer auto Pingback[…] Add "virtual" keyword support. http://bugs.adobe.com/jira/browse/ASC-743http://probertson.com/articles/2005/10/ … 2_not_as2/Here’s some info I could find. But the links are a little bit out of date. Even though it’s correct […]


  30. Некоторые пояснения по синтаксису ActionScript 3. | RIA crumbs. RIA development related blog is reported to have said:

    […] Сами пояснения читать тут. […]


  31. ialmeida's as3 Bookmarks on Delicious is reported to have said:

    Kramer auto Pingback[…] ActionScript 3 Syntax preview, a bunch of Words, punctuated - by Paul Robertson (http://probertson.c… SAVE […]

Add your comment





Comment notes

Please keep comments on topic. Comments that are inappropriate or offensive will be edited or removed.

Paragraphs and line breaks are automatically converted to HTML, and quotation marks are converted to “smart” quotes.

The following XHTML tags can be used: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> . All others will be removed.

Articles by Type

Articles by Topic

Random Reading

Currently...

Subscribe