I just found a nasty little bug in Flash CS4. One line of code will result in a project that compiles with no errors and yet no trace statements work either.
Simply put the following line of code anywhere in your project (including in any class, or on any frame on the time line):
var version:Number = 0.0.1;
That’s it! Your project will (seem to) compile with no errors.
You won’t get any trace output either.
Imagine burying this line of code in a random class in a project that has hundreds of classes. How could anyone find it?
I’m Tellin’ Y’all It’s a Sabotage.
Modules are SWF files that can be loaded by an application but cannot run indepedently. Modules are built in to Flex 3, but it takes a bit of finagling to use modules in Flash.
I have been able to use modules successfully in Flash. Below are the steps to follow. I have also included the sample source code:
Grab the latest Flex SDK. I used 3.2:
In the Flash IDE (I’m using CS4), create a reference to the Flex SDK:
File > Publish Settings > Flash > Settings > Library Path
Add a reference to frameworks\libs (see the following image)
Advanced ActionScript 3.0 Settings
Create a module by creating a class that extends mx.modules.ModuleBase.
public class ModuleAlpha extends ModuleBase implements IModuleAlpha
public function ModuleAlpha()
public function addNumbers(a:Number, b:Number):Number
return a + b;
Compile the module using the mxmlc command line compiler.
Note: If you’ve placed your source in subdirectories, you will need to let the compiler know your source path.
In my example, ModuleAlpha.as is located in the com.electrotank.modules package.
Thus, here is my command to compile:
>mxmlc "-source-path+=../../../" ModuleBeta.as
Create a “parent” application that will load in your module(s) via mx.modules.ModuleManager.
Here is an excerpt from the sample code provided:
private const URL_MOD_ALPHA:String = "ModuleAlpha.swf";
_modules[URL_MOD_ALPHA] = ModuleManager.getModule(URL_MOD_ALPHA);
Create an instance of your newly uploaded module using the factory of IModuleInfo:
var modAlpha:IModuleAlpha = IModuleAlpha(IModuleInfo(_modules[URL_MOD_ALPHA]).factory.create());
Be sure to use your powers only for good and not evil.
When Flash introduced the copyPixel operation a few versions ago, I was very excited. Finally, I could create blazing fast games that worked more like “real” games instead of using MovieClips. However, copyPixel is no magic bullet.
Here are the results of a simple test where I scroll a background image. I guessed that copyPixel would yield the fastest results, but I was wrong.
Note that during initial testing it was difficult to get a big difference with an 800×600 drawing area.
Of course, that’s because I’m only moving 1 image around as opposed to hundreds as in an actual game.
Thus, to make the differences stand way out, I increased the drawing area to 1880×1024.
This will fill up Fire Fox if your resolution is 1920×1200, but you can still see the drawing area.
The frame rate is set to 120.
Note also that I am using a crazy big image of size 4095×4095 (3.5 Megs).
Various OSs and Browsers
||Fps Fire Fox - Win
|| Fps Internet Explorer - Win
|| Fps Fire Fox - Mac
||120 solid (wow)
||120 solid (wow)
So, the really confusing thing for me is that copy pixel seems to drag down gpu mode!
Also, remember when “opaque” used to be the best wmode option for performance? Not any more (at least for this specific test).
I am running Flex 3 on Windows Vista. For some reason, attempting to profile an application would always fail. There were no errors or warnings… the app would launch in my browser and simply run without profiling.
The following work around worked for me:
- In Flex 3, click on Window > Preferences…
- In the Preferences window, choose Flex > Profiler > Connections
- Set the Port number to something other than 9999. 10001 worked for me.
Profiler Preferences Window
Bugs, Flex 3