Skip to content

Instantly share code, notes, and snippets.

@gnat
Last active March 16, 2024 08:46
Show Gist options
  • Save gnat/2044855706c4e8164307ab7853a19056 to your computer and use it in GitHub Desktop.
Save gnat/2044855706c4e8164307ab7853a19056 to your computer and use it in GitHub Desktop.
Why AS3 sucks and was a terrible direction for Flash (Actionscript 2 vs Actionscript 3)

Why AS3 was a terrible direction for Flash

tl;dr

  • AS3 requires you be an expert in it.
    • No longer accessible to people without a programming focus (artists).
      • Previously possible projects become too difficult in a reasonable timeframe.
      • I teach Flash to designers [...] the threshold of entry as well as the intimidation factor became too high for design students. What they want to do is make something functional and beautiful without needing to spend weeks learning the basics. AS2 made that possible. AS3, to a huge degree, took it away.

      • I'm a designer. [...] I've spent incomprehensible amounts of time learning and re-learning ActionScript. When AS3 was released I took one look at it and threw in the towel. Since then my life has been much better.

      • Surely as memory/processor constraints dwindle, programming should be becoming LESS verbose, not more. Write less, do more, quicker. Hide the complexities of common tasks in simple short terms, not have to write a hundred lines to get the simplest thing done. To all the code snobs who think that productivity comes from complexity, should we go back to machine code and altering bits at a time in registers, or perhaps the real coders should go back and use 100 pages of punch cards with cut out dots to insert a simple gotoAndPlay. Personally i prefer to make the machines work for me, not me working for the machines, which is what actionscript 3 feels like.

  • Simple calls in AS2 are often blown up to multiple lines involving multiple objects in AS3.
  • Too much complexity imposes copy/paste (or autocomplete) for experienced programmers.
    • Long term lowers maximum scripted functionality of app/game.
  • AS2 code was scoped 1:1 with what you could see.
    • Scoping was based on movie clips you could grab and move around.
  • More ceremony in AS3 to cargo cult into being more "java like"
    • Less time to spend in other areas.
    • Friction will kill your project.
    • Eventually forces your project into packages + classes style not needed in AS2.
      • MovieClips are already a form of module! How far we've strayed from "add scripts to MovieClip".
      • Turns 1 layer of scoping into 3.

What exactly?

  • No simple way to purge loaded .swf files.
    • Introduces memory management when this was fully automatic in AS2 !
  • Removal of on() / onClipEvent() for easy MovieClip event handling.
    • AS2 lets you override 1 function per event type on a MovieClip. Add detail inside the function.
    • AS3 you must define the supporting listener and functions seperately for each event type.
  • Getting parent movie clip is unintuitive for something that must be done all of the time (artists use it for timeline control).
    • AS2: this.parent.play();
    • AS3: MovieClip(this.parent).play();
      • The AS2 example will error in AS3; velocity killer.
  • Removal of duplicateMovieClip() makes cloning a MovieClip instance (really) hard.
  • Removal of getURL() makes linking hard.
    • AS2: getURL("http://www.oreilly.com");
    • AS3: navigateToURL(new URLRequest("http://www.oreilly.com"));
  • Removal of loadMovie() makes loading .swf files and images hard.
    • AS2: parent.loadMovie("animation.swf");
    • AS3: var l:Loader = new Loader(); l.load(new URLRequest("animation.swf")); MovieClip(this.parent).addChild(l);
  • Referring to library symbols dynamically is unintuitive.
    • AS2: parent.attachMovie("Animation" + 1, "instance" + 1, 0);
    • AS3: var Symbol; Symbol = getDefinitionByName("Animation" + 1); parent.addChild(new Symbol());
  • Attaching new child MovieClips dynamically.
    • AS2: addChildFromLibrary(parentClip, "Animation" + i);
    • AS3: Literally a 10+ line ordeal to walk the entire project tree to find the correct MovieClip, then attach. 😟
      • This time vampire image
  • Adding custom functionality to manually created text fields, to all movie clips, or to all buttons is cumbersome.

Resources

Notes

  • Flash CS6 was the last version to support Actionscript 2

image

Typical real world MovieClip example.

  • Guy trades simple memorable flat functions ➡️ for Javascript event listeners and a switch/case check.
  • JS style is not terrible if you're familiar with the style in the browser, but we gave up a frictionless Actionscript for it.
  • Left side is simple enough to remember. Right side is ok if you're working with Javascript all day.
  • Screenshot from 2023-08-27 18-30-20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment