views:

170

answers:

2

Over the past three weeks, I have lost at least 120 man hours because of some lesser known functionality in ActionScript 3. One of the problems was that, with Internet Explorer, if there are too many messages sent through LocalConnections, it will slow the messages sent through, but in the standalone player and in Firefox, this threshold is significantly higher. Another was that the static values of a class are instantiated even if the member itself is not being used:

import path.to.FooClass;

private function thisIsNeverCalledButItEnsuresThatFooClassIsImported():void
{
    var f:FooClass = new FooClass();
}

Since FooClass had a static reference to a Singleton, that Singleton was instantiated so when I loaded a Module which used that Singleton, it would bind to values in an unpredictable way.

Additional cases where things behave in an unexpected way:

  • MovieClip.addFrameScript
  • flash.trace.Trace as a class
  • int is a faster incrementer class, Number is faster for mathematics, and uint is incredibly slow.
  • PrintDataGrid, if it has only one page, needs to have an empty value appended to the end of its dataProvider
  • If you use try...catch around two LocalConnections and connect them to the same channel, you will force garbage collection without needing System.gc

So here's the question (and I'm sorry for omitting this in the original post), is there any consolidated documentation for this type of behavior anywhere? Is there any (even non-Adobe) documentation on these issues (websites, forums, books, ANYTHING)? I know that these things are definitely easy enough TO document, but has anyone done so?

If not, am I missing anything? Are there other issues which I should know about?

A: 

This kind of useful information is very often not "centralized". Moreover, what you are looking for is something related to the experience of the programmer (more than to official docs).

I was afraid of that. It seems, however, that with Flex, there needs to be more centralization than, say, with PHP, JavaScript or Java. It is a shame that it does not exist. Still, it is far better than JSFL, I suppose.
Christopher W. Allen-Poole
A: 

FYI, there are two other methods for ensuring a class is included.

#1 - This syntax is actually used in the Flex source code:

import path.to.FooClass; FooClass; // note double reference

public class References
{
    // No references needed in this class
}

#2 - Use the includes command line argument

-includes path.to.FooClass
Richard Szalay