Skip to main content

Books: ActionScript 3.0: Visual QuickStart Guide

I finished reading ActionScript 3.0: Visual QuickStart Guide. All-in-all, it wasn't bad. I needed to learn ActionScript quickly, but not extremely deeply, and it helped me do that.

This is the first time I've read a visual quickstart guide. The book was only about 300 pages, and each page was cut in two columns. The inner columns have code, and the outer columns have prose. Hence, there's only about 150 pages of prose. The code tended to be very basic and very redundant. Unsurprisingly, the author was a non-software engineer who learned how to code in ActionScript. I sort of expected that. The book wasn't perfect, but I definitely recommend it if you're a software engineer who needs to learn ActionScript in a hurry.

That's enough for the book review. Now, let me say a few words about ActionScript. First of all, ActionScript 3.0 is a compiled language. ActionScript started life as ECMAScript, but by the time they hit 3.0, it had morphed into a pleasant mix of JavaScript and Java. It has static types like Java, but you can do a lot of the same tricks that you can do in JavaScript, such as treat objects as hashes and use closures. Like JavaScript, ActionScript revolves around event handling. Anyway, as I said, I think ActionScript 3.0 is pleasant.

Now, let me cover a few of the things that were interesting enough for me to write down while I was reading the book.

ActionScript 3.0 has three types of numbers: int, uint, and Number. Numbers are floats, and match the same number type that JavaScript has.

One way to think of Flash is as a programmable version of Photoshop optimized for animated gifs. That's pretty much how it started life. Over time, they added layers and timelines. These days, ActionScript is a full featured language. Early on in the book, I couldn't understand how this graphical environment and this programming language worked together. Now I understand that Adobe Flash CS 4 is basically something like a paint program with a timeline that you use to create movies. ActionScript is bolted onto the side of it so that you can control things programmatically. However, early on, the most important use of the programming language was simply to control the timeline of the movie. (I could be getting some of this wrong since I've only been coding in ActionScript for a few months.)

Using the open source Flex SDK, you can compile Flash from the command line. You can even shun Adobe Flash CS 4 entirely and code everything in Vim. Although there are rather nice Flash IDEs, I felt less out of my element by sticking to Vim. See my other three posts: Linux: Installing the Flex SDK, Vim: Editing ActionScript, and Linux: Installing the Debug Version of Flash on Ubuntu.

Whereas in Java you might write "FooBar fooBar = new FooBar();" in ActionScript you write "var fooBar:Foobar = Foobar();". I think I have a mild preference for ActionScript's syntax.

There is a widget hierarchy in ActionScript. As you go down the hierarchy, the widgets gain more behavior such as being able to accept events or being able to contain other widgets. MovieClip is pretty far down in the hierarchy and is used for almost everything. MovieClip doesn't actually have anything to do with playing videos. It's just a widget that can handle events, contain other widgets, and live in its own timeline.

In C, to cast an int, you might write "(int) n", but in ActionScript, you write "Number(n)".

TextFields in ActionScript do support HTML, but its very weak. They also support CSS, but that's pretty weak too.

"someArray.forEach(someFunction);" works.

Just like JavaScript, you can write 'if (typeof(s) == "string")'. However, to test what type of object you have, you can also write 'if (someObj is MovieClip)'.

Use "for (var i:String in someObj) { trace(someObj[i]); }" to loop over the indexes of an object.

Use "for each (var value in someObj) { trace(value); }" to loop over the values of an object.

Use "navigateToURL" (mentioned on p. 205) to make the browser go to a new web page.

The way you dynamically load data from a web site varies wildly depending on whether you're loading sound, a DisplayObject, or data. I'm pretty sure these things were built by different engineers at different times.

In summary, if you're familiar with JavaScript and Java, ActionScript will seem extremely straightforward. I managed to code quite a bit before picking up a book at all.


bsergean said…
I've written a build system for Flash Builder at work and I'd love if we could to open-source it. It takes a list of flex projects (.swc and .swf) as input (in an XML file) and build them, resolving the dependancies and building in parallel (clean build).
jjinux said…
jjinux said…
By the way, how would it compare to Ant, since Ant seems to be pretty standard for Flash?

Popular posts from this blog

Drawing Sierpinski's Triangle in Minecraft Using Python

In his keynote at PyCon, Eben Upton, the Executive Director of the Rasberry Pi Foundation, mentioned that not only has Minecraft been ported to the Rasberry Pi, but you can even control it with Python. Since four of my kids are avid Minecraft fans, I figured this might be a good time to teach them to program using Python. So I started yesterday with the goal of programming something cool for Minecraft and then showing it off at the San Francisco Python Meetup in the evening.

The first problem that I faced was that I didn't have a Rasberry Pi. You can't hack Minecraft by just installing the Minecraft client. Speaking of which, I didn't have the Minecraft client installed either ;) My kids always play it on their Nexus 7s. I found an open source Minecraft server called Bukkit that "provides the means to extend the popular Minecraft multiplayer server." Then I found a plugin called RaspberryJuice that implements a subset of the Minecraft Pi modding API for Bukkit s…

Apple: iPad and Emacs

Someone asked my boss's buddy Art Medlar if he was going to buy an iPad. He said, "I figure as soon as it runs Emacs, that will be the sign to buy." I think he was just trying to be funny, but his statement is actually fairly profound.

It's well known that submitting iPhone and iPad applications for sale on Apple's store is a huge pain--even if they're free and open source. Apple is acting as a gatekeeper for what is and isn't allowed on your device. I heard that Apple would never allow a scripting language to be installed on your iPad because it would allow end users to run code that they hadn't verified. (I don't have a reference for this, but if you do, please post it below.) Emacs is mostly written in Emacs Lisp. Per Apple's policy, I don't think it'll ever be possible to run Emacs on the iPad.

Emacs was written by Richard Stallman, and it practically defines the Free Software movement (in a manner of speaking at least). Stal…

Creating Windows 10 Boot Media for a Lenovo Thinkpad T410 Using Only a Mac and a Linux Machine

TL;DR: Giovanni and I struggled trying to get Windows 10 installed on the Lenovo Thinkpad T410. We struggled a lot trying to create the installation media because we only had a Mac and a Linux machine to work with. Everytime we tried to boot the USB thumb drive, it just showed us a blinking cursor. At the end, we finally realized that Windows 10 wasn't supported on this laptop :-/I've heard that it took Thomas Edison 100 tries to figure out the right material to use as a lightbulb filament. Well, I'm no Thomas Edison, but I thought it might be noteworthy to document our attempts at getting it to boot off a USB thumb drive:Download the ISO. Attempt 1: Use Etcher. Etcher says it doesn't work for Windows. Attempt 2: Use Boot Camp Assistant. It doesn't have that feature anymore. Attempt 3: Use Disk Utility on a Mac. Erase a USB thumb drive: Format: ExFAT Scheme: GUID Partition Map Mount the ISO. Copy everything from the I…