Articles Archive
Articles Search
Director Wiki

Comparing Lingo and ActionScript, Part II

March 22, 2001
by Gary Rosenzweig

In last week's article, we started comparing Director's Lingo and ActionScript in Flash by looking at script placement, variable scoping, and operators. In this week's installment, we'll finish off our look at the two scripting languages.

Code Framing

In Lingo, the term end is used to frame a section of code. It is used at the end of a loop or at the end of a handler. In ActionScript, the curly brackets or braces {} are used just like in C++ or Java.

Handlers and Functions

In Lingo, everything is in a handler. All handlers start with on which is then followed by the name of the handler. This could be an event, like on mouseUp or some custom handler like on computeScore.

In ActionScript, functions take the place of handlers. They use the word function in place of on and are framed with braces instead of on...end.

In addition to functions, there are clip event handlers that are only valid when used as part of a movie clip instances object script. These start with onClipEvent followed by the name of a specific event, like enterFrame. Here is an empty one:

onClipEvent (enterFrame) {

     // nothing


This is the same as the Lingo enterFrame handler, except that you can't place it on a frame. Instead, it is attached to a movie clip instance in a manner similar to how a behavior would be attached to a sprite in Director.

In addition, Flash buttons can have button event handlers in their scripts. To make it a little more confusing, these do use the on syntax. So a button script may look like this:

on (press) {

    // nothing



Director uses script-like syntax for loops. The key word is repeat. A typical loop will look like this:

repeat with i = 1 to 10

  -- do something

end repeat

In Flash, you use the more common for keyword, along with syntax like you would use in C.

for (var i = 1; i <= 10; i++) {

    // do something


The three parts of the for statement parameters define the loop. The first part declares a variable i and sets its initial value. The second part is the condition under which the loop will continue to loop. The third part is the change that will occur after each and every loop.

Lingo also has repeat while loops. These are do while loops in ActionScript.


ActionScript string handling is pretty similar to Lingo. Instead of the & symbol for concatenating two stings, just use a + symbol. Unfortunately, there is no equivalent for the && command.

One of the cool, somewhat hidden features of ActionScript is its ability to use the += assignment to add something to the end of a string. This is the same as put ... after in Lingo:

myString += ".";

Lists and Arrays

Lingo uses lists, which Director programmers will explain to other programmers is our term for arrays. There are two types of lists: linear lists and property lists.

ActionScript uses arrays instead of linear lists. To add an element to the end of a linear list, you use the push command. To remove one, you can use pop (last item), shift (first item), or splice (arbitrary item). The equivalents in Lingo are add and deleteAt. ActionScript uses the length property to get the number of elements in an array while Lingo uses count.

There are no property arrays in ActionScript. However, you can create data objects that are similar, but less versatile. For instance, consider this ActionScript line:

myObject = {name: "Apple", color: "Red", number: 7};

Now you can call on parts of this object like this:

trace (;


For speed, there is no comparison. Lingo beats ActionScript by a mile. As an example, I wrote a simple piece of code that slowly finds all of the prime numbers between 1 and 1000. The Lingo and ActionScript match each other line for line. You can find the source code as part of the download at the end of this column.

ActionScript takes 15 seconds to find all of the primes. You'll notice that the code has a line commented out that will put each prime found into the Output window. I decided that the trace command shouldn't be part of the test.

Similarly, I took the put command out of the Lingo code. The result is about 0.33 seconds. That's 45 times faster.

This one test doesn't mean everything, but take my word for it as an experienced programmer of both languages: Lingo is much faster.

Which One to Use

Lingo and ActionScript are similar and yet different. So, which one should you use? The answer is . . . there is no answer. Perhaps one language is easier than another for you to learn. Perhaps using the smaller Flash plugin fits better with your plans. Or, perhaps Director's expandability with Xtras is necessary for your project.

This is becoming the question that I am asked most: Should I use Director or Flash? The only answer I have is that in some cases the choice will be obvious. In other cases it will not. In those situations, go with whichever tool you know best.

Sample Director 7 and Flash 5 files are available for download in Mac or Windows format.

[Editor's Note: Lingo Lounge will be taking next week off, because Gary's in San Jose speaking this weekend at the Game Developers Conference.]

Gary Rosenzweig is the author of six books on Macromedia Director and Flash. He also publishes a weekly email newsletter for Flash and Director developers called the Developer Dispatch. You can subscribe to this newsletter at

Gary Rosenzweig is the Chief Engineer, founder, and owner of CleverMedia, a game and multimedia development company in Denver, Colorado. He is the author of ten books on Macromedia Director and Flash, including his latest, Special Edition Using Director MX.

Copyright 1997-2017, Director Online. Article content copyright by respective authors.