Problems & Solutions

RegExp matching unterminated ActionScript lines (semicolon)

Posted in Adobe Flash, Problems & Solutions on February 4th, 2010 by Øyvind – Be the first to comment

Skjermbilde 2010-02-04 kl. 11.40.44

Today I had the dreaded “1131: Internal build error” in Flash Builder coupled with the “Classes must not be nested error” despite no classes actually being nested. Googling around, I found a few posts that provide some tips towards a solution. The most frequent two of which are empty switch statements and ActionScript lines that are not properly terminated with a semicolon. The project in questing uses over 100 classes, so I decided to create a RegExp for use in “Find In Files” to search for lines that were not properly terminated.

As an extra caveat, many types of lines in programming are not supposed to be terminated, so the RegExp is quite long and I have not been able to test it any more than the said 100-class project I’m working on.

NOTE: This might macth some multiline ASDoc comments, empty lines and method argument lists spanning multiple lines as well.

(?sim)(?<!/\*)^\t*((?!\{|\}|@)(?!function|import|class|embed|SWF|if|else|switch|case|while|for|event|try|catch|finally|package|default|//|/\*|\*/)[^;])+$(?!.*\*/)

Here are the posts I found:

EDIT: Added “default” to the RegExp. If anyone has any improvements to this, please let me know. Especially on how to make it not match so many empty lines.

Stangle your bandwidth with Entonnoir (free)

Posted in Adobe Flash, Problems & Solutions on March 3rd, 2009 by Øyvind – 2 Comments

EntonnoirJust found this surrealistically fantastic app that’s really useful for web developers. Entonnoir let’s you select how fast you want your mac’c internet connection to be. And when you’re on 100 Mbit at the office trying to test a preloader, it really comes in handy. It’s free too, so what are you waiting for?

Download Entonnoir

Asset SWF, loading/embedding has fundamental differences

Posted in Adobe Flash, Problems & Solutions on December 4th, 2008 by Øyvind – Be the first to comment

Embed or getDefinition

So after a few headaches I arrived at a thesis (at best): If developing and compiling in Flex Builder, but using a library of assets (in the form of a SWF-file) compiled by the Flash IDE, loading the assets.swf at runtime and embedding are not going to give you equal access the assets and their associated classes. Loading the asset SWF will enable you to use:

loader.contentLoaderInfo.applicationDomain.getDefinition("MySymbolClass")

That will return a class definition of the library symbol and it’s associated custom class and base class.

However:

[Embed(source="assets.swf", symbol="MySymbol")]
var MySymbolClass:Class;

will yield, put simply, the most descriptive, built-in class able to describe the symbol. But that’s at the discretion of the compiler. So if I have a button with an associated custom class, let’s say FancyButton, in assets.swf, that code will be elegantly ingnored by the Flex compiler and I’m only able to datatype the button as Sprite or MovieClip (if it has more than one frame). So I’m guessing the philosophy behind the embed compiler directive is that it is meant for embedding primitive assets, like bitmaps, sprites, fonts and so on into the class that adds the fancy, custom code, while loading and using getDefinition is the only way that will allow the assets to have custom code associated with them.

As seen in the photo comic above from the 70′, this discussion might have been going on for a while without me knowing it. I think I will be loading my asset SWF at runtime from now on unless someone has a good reason for me not to.