Header Image - charles newman's blog

Category Archives

30 Articles

Adobe Flex – Project build order setting in preferences

by Charles Newman

Do you ever get baffling build errors after importing projects? Sometimes the compile errors are related to project settings, such as library dependencies, missing SWC files etc.  But after fixing those problems you still see errors after doing a “Clean…”?

Take a look at your build order preferences, you’ll find the dialog shown below under the Flex Builder preferences (Cmd+”,” on a Mac), not the project preferences.  Apparently, Flex Builder adds items here in the order you import them, so mix them up here based on dependency and when you tell Flex Builder to “Clean..” it should build everything correctly.


Adobe Flex – Use working sets to manage your projects

by Charles Newman

If you have a lot of projects in Flex Builder you can use working sets to make them more manageable.

In the Flex Navigator view (this is the project tree), click on the toolbar menu and select “Select Working Set”. Click the “New…” button. Choose “Resource” and click “Next >”. Give your working set a name and then choose the projects that go in it.

This is a huge productivity boost, not only for working with projects, but also for searching across your source code. When you do a “find in files” (cmd+shift+F), you can select a working set to search in.

Google Picasa Web API – some photos will not load in IE and Safari

This baffled me for a few days.  I wrote a Flex app to try out Google’s Picasa Web API and it worked great in Firefox on a Mac.  But some of the images would not load in Safari (Mac or PC) and IE 7.  I eventually stumbled on a query string param that fixed it.

Apparently, some browsers limit the size of images to 800 pixels for the largest dimension.  If your images will not load in IE and Safari, try adding “imgmax=800” on the query string when you request an image, like this:


Adobe Flex – Loading a SWF at Run-Time

by Charles Newman

It is typical of a plug-in architecture to load SWFs at run-time.  When I started doing this I realized that SWFs built in Flex look a little different than those built in Flash.

Here is some sample code:

var loader:Loader = new Loader();
var req:URLRequest = new URLRequest(url);
var context:LoaderContext = new LoaderContext();
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSwfLoadComplete);
loader.load(req, context);

private function onSwfLoadComplete(e:Event):void {
 var content:DisplayObject = e.target.content;
 var plugIn:IPlugIn;
 // If we don't add it as a child to something, it won't be in the
 // display list and the stage property will be null
 // and Flex will puke, so in this case "plugin_container"
 // is just a mx:UIComponent
 // with it's visible property set to false

 // If the plug-in was written in Flex, content
 // will be the SystemManager
 // and we need to wait for the Application object
 // to finish loading
 if (content is SystemManager) {
  var sysmgr:SystemManager = (content as SystemManager);
 else {
  if (content is IPlugIn) {
   plugIn = content as IPlugIn;
   // now you can call a method on your interface such as:

private function flexPlugInAppComplete(e:FlexEvent):void {
 var sysmgr:SystemManager = (e.currentTarget as SystemManager);
 var swfApp:Application = (sysmgr.application as Application);

 // this is whatever you are using for a plug-in interface
 var plugIn:IPlugIn;

 if (swfApp is IPlugIn) {
  plugIn = swfApp as IPlugIn;
  // now you can call a method on your interface such as:

Flex – Bindable Array Problems

by Charles Newman

Generally, it is not a good idea to bind to an Array object because Flex can’t detect changes to the array. So if you are dynamically adding items to your Array, you probably won’t see the changes at run-time.

I’ve found two workarounds for this:

1) Use an ArrayCollection. Not as fast as Arrays, but bindable at least.
2) Create a temporary array and assign it at run-time to your bound array.

Flex Builder 3 General Tips and Productivity Enhancers

by Charles Newman

Show all shortcut keys:
Cmd-shift-L (Ctrl-shift-L on Windows)

Hide SVN files in the Flex Navigator view:
Click on the down arrow in the upper right corner of the Flex Navigator view and select “Filters”. Click the last check box “.*”. Click OK.

No need to type “mx:”
Just start typing the tag name you are looking for and then select from the code hinting list, the “mx” prefix will be added for you.

Change case
Cmd-shift-x (Ctrl-shift-x on Windows) to change to upper case, Cmd-shift-y to change to lower case.

Find matching brace
Cmd-shift-P (Ctrl-shift-P on Windows) to find the matching ActionScript brace.

Go to an object’s definition
Click on a variable, hold down the Cmd key (Ctrl key on Windows, maybe) and click when the underline appears.

Pop up the AsDoc entry
Select an mx tag, hit shift-F2

Sending Trace Statements to a log file with the Debug version of the Flash Player

Sometimes it’s more efficient to “tail -f” a log file rather than set breakpoints in your authoring environment. This is kind of an “old school” technique for Flash developers and was absolutely necessary for debugging ActionScript “back in the day”. But today this is still a very valuable debugging technique, especially if you are debugging a timing issue.

To do this you need to create a file called "mm.cfg" in the following location:

/Library/Application Support/Macromedia

Windows 2000/XP:
C:\Documents and Settings\username\mm.cfg

Windows 7:

Add the following lines to the file:

Load your swf with trace statements and in the following location you should (eventually) see a file called “flashlog.txt”:

/Users/yourname/Library/Preferences/Macromedia/Flash Player/Logs

Windows 2000/XP:
C:\Documents and Settings\username\Application Data\Macromedia\Flash Player\Logs

Windows 7:
C:\Users\username\AppData\Roaming\Macromedia\Flash Player\Logs

For up-to-date locations of the mm.cfg, the log file, and other properties you can set in the mm.cfg file see this page from Adobe.


”’Not Working?”’

If you are having problems getting the player to write to flashlog.txt, make sure you have the debug version of the player installed, you can get Flash Player versions here:


Check your "mm.cfg" file: make sure it is in the correct place and if you created it with TextEdit for example, make sure it has no RTF stuff in it (open it with "vi" in a terminal window).

Helpful tip:

You can also watch the log file via the Mac OS X Console app. Windows users can search Google for a utility called “WinTail” which gives you “tail -f” functionality in a command window.