Said,
> Please tell me advantages and disadvantages of both
> [versions of] ActionScript. Please advise which is
> powerful and has more info and sources.
ActionScript 1.0 and 2.0 both run on the same virtual
machine (AVM1)
inside Flash Player. As of Flash Player 9, the player runtime
features two
virtual machines (AVM1 and AVM2), the second of which runs
ActionScript 3.0.
Right off the bat, this tells you that Flash Player 9 or
higher is required
if you want to program with ActionScript 3.0. In one sense,
that's a
potential "disadvantage" of AS3: if your users have Flash
Player 8 or lower
installed, you simply can't use that version of the language.
Instead,
you'll have to use AS2 (as far back as Flash Player 6) or AS1
(as far back
as Flash Player 5), or slash-notation proto-ActionScript if
you need to go
even further back than that. Ultimately, then, the version of
ActionScript
you use depends on the version of Flash Player you expect
your users to have
installed.
AS2 is the first version of ActionScript to officially
support custom
classes (external text files structured in a particular way,
using folders
for classpaths and the "class" keyword). For more information
on
classpaths -- written for AS2, but basically applies to AS3
-- see this URL:
http://www.quip.net/blog/2006/flash/understanding-classpaths
For many people (myself included), custom classes provide a
powerful way
to organize code into reusable objects -- just like the given
objects in
ActionScript's native API. Be aware, however, that custom
classes are *not
a required workflow* in AS2 or AS3. If you prefer, you may
place your AS2
or AS3 code into timeline keyframes, just like with AS1.
Contrarily, even
though true classes are not officially supported by AS1, you
can mimic many
of the benefits of classes by following the instructions here
(an incomplete
resource, but very useful):
http://www.debreuil.com/docs/
It would take pages and pages of notes to give you a
thorough list of
the benefits (and disadvantages!) of every version of
ActionScript. Even
then, it would be difficult to demonstrate that such a list
was complete, so
to keep things simple: as a general rule, each new version of
ActionScript
is presumed to be better than its predecessor. AS1 was more
powerful than
Flash 4-era ActionScript because it provided a considerably
larger API. AS1
also made it easier to target objects with dot notation than
with slash
notation and cumbersome getProperty() and setProperty()
functions. AS2 was
more powerful than AS1 because it provided native support for
classes. It
introduced variable typing, which helped with code completion
and
compile-time error checking. (AS2 also coincided with an even
larger API,
but that's a parallel benefit due to increased functionality
in subsequent
versions of Flash Player.) AS3 is more powerful than AS2
because the syntax
of custom classes has become more strict. I personally find
that stricter
syntax helps a programmer avoid "lazy" or "sloppy" practices,
encouraging
the programmer to code with purpose.
For more thoughts along these lines, here's a free excerpt
from a book I
recently co-authored for O'Reilly (bear in mind, these are
largely
subjective opinions, but they work for me):
http://www.communitymx.com/abstract.cfm?cid=16D76
I'll probably start repeating myself soon, but to sum up:
AS2 has
advantages over previous versions because it provides
numerous options and
improvement in ease of use. AS3 improves even further by
"cleaning up" the
language by making it more strict and by providing a stronger
internal
consistency.
Here are a few quick examples.
In AS2, to create an instance of the Sound class (that is,
an object you
can use for programming audio), you simply use the "new"
keyword:
// AS2
var mySound:Sound = new Sound();
Most classes can be instantiated in this way, but in AS2,
there are
notable exceptions, including movie clips and text fields.
// AS2 -- this does NOT work!
var myMC:MovieClip = new MovieClip();
var myTF:TextField = new TextField();
This can be confusing to a newcomer, because it seems so
arbitrary.
(Someone new might well think, "Why can't instances be made
the same way
across the board?") In AS3, instantiation is more consistent:
// AS3
var mySound:Sound = new Sound();
var myMC:MovieClip = new MovieClip();
var myTF:TextField = new TextField();
This is also true for event handling. In AS2, there are four
or five
ways to do it: the on() and onClipEvent() functions, their
dot notation
equivalents, addListener(), and addEventListener(). They're
all valid in
AS2, but not all interchangeable. Some work for components,
some for other
sorts of objects. It takes effort to memorize which objects
work with which
approach. In AS3, outside of a very small number of
exceptions, most event
handling is done with a single, consistent approach:
addEventListener().
For a newcomer, this is easier to learn because once the
technique is
understood, it works in nearly every scenario.
As far as performance is concerned, AS3 trumps AS2
significantly. AS3
performs better and faster than all previous versions of
ActionScript -- but
you'll only notice this with complex applications, especially
those
involving a high volume of number crunching.
Here are a few more links that may prove helpful to you:
ActionScript 3.0 Overview
http://www.adobe.com/devnet/actionscript/articles/actionscript3_overview.html
Tips for Learning ActionScript 3.0
http://www.adobe.com/devnet/actionscript/articles/actionscript_tips.html
ActionScript 3.0: Is it Hard or Not?
http://www.insideria.com/2008/01/actionscript-30-is-it-hard-or.html
You also asked which version of the language has more "info
and
resources." By that, I assume you mean online resources, such
as blogs,
tutorials, and so on. That question is hard to answer, but my
*guess* is
that there are still more resources online about AS2 than AS3
... but AS3
will probably catch up soon.
David Stiller
Co-author, Foundation Flash CS4 for Designers
http://tinyurl.com/5j55cv
"Luck is the residue of good design."