September 05, 2008

Using the Flex Builder 3.x Profiler

I've been getting lots of questions about memory leaks lately. I finally found some time to put my techniques for analyzing memory leaks into writing.

Instead of using PowerPoint, I actually created a SWF so you can use the SWF to both view the presentation and learn how to use the Profiler. I cover the differences between profiler memory, System.totalMemory and process memory and show how I analyze the two most common memory leak scenarios.

Run Presentation

As usual, caveats apply.

The SWF also demonstrates an approach to another topic I've heard about often, and that is how to do XML-driven or data-driven UI. The presentation in this SWF is controlled by an XML file. A single engine parses the XML and creates the UI widgets as dictated by the XML. To change the presentation, all I have to do is change the XML. I can also add new widgets easily. Source is available here:

Download FlexBuilder Project

The SWF also demonstrates a technique for improving startup time. Because our blog system is painful to use, I don't like uploading more than one or two files per blog post, but this presentation had more than a dozen images. So, instead of loading images externally, I embedded them into the SWF, but normally, that delays startup by the download time of all of those images. To get around that, I pack all the images into frame 3 of the SWF so that Flex can get up and running while the images download at the end of the SWF. I can get away with that because the images are not needed right away.

Hope this helps.

August 19, 2008

Flex Authority Magazine

I think I can finally say I got something published! Gordon Smith and I contributed to the first issue of Flex Authority, a new magazine (made of actual paper!) that focuses on Flex and AIR. We hope to be regular contributors. The link to find out more is: http://www.flex-authority.com/. Buy your subscription today. We won't make any money from it, but this post is to thank them for working with us and to help them get the word out so they can make some money.

Marshall Plan At 360Flex Conference

Today I presented more information about the Marshall Plan at the 360Flex conference in San Jose. The PowerPoint presentation can be downloaded here.
Download Presentation

There is a series of demos in the presentation. The code and source are linked below. To get the third child to load you will need to download zoomer.swf and copy it to a server somewhere and fix the URL that loads it

Zoomer is a simple app that has a rectangle you drag around and it will magnify the area under the rectangle. The demo shows how it needs to be modified for being loaded by a main application in different applicationDomain and securityDomain configurations

Pattern 1 would the the standard first attempt. You can run zoomer.swf and see how it works on its own, run mainApplication.swf and see how, when zoomer is loaded, you can't drag the rectangle out of the area owned by zoomer. See slide Demo #1.

Run Zoomer
Run Zoomer as a sub-app

Pattern 2 works for the first copy of Zoomer, but not for the second or third. See the slides for Demo#2

Run Zoomer
Run Zoomer as a sub-app

Pattern 3 uses getSandboxRoot() so the first and second copy of Zoomer works, but still the third is broken. See slide for Demo#3.

Run Zoomer
Run Zoomer as a sub-app

THe Final Pattern fixes that by listening for MarshalMouseEvent. See slide Demo#4

Run Zoomer
Run Zoomer as a sub-app

Source code is here:
Download Source
You will need a pre-release of 3.2 to build the source.

Preliminary write-up on the Marshall Plan is here:
Marshall Plan Wiki

As usual, caveats apply to all content

August 05, 2008

DataGrid With PopUp Editor

Some folks seem to be in need of an itemEditor in the DataGrid that can popup or float over the DataGrid. The DataGrid currently limits the editor to fit within its size and if you need more space than that, you'll need to popup an editor.

It is tricky to do so because of a bug in DataGrid plus the complexities of focus handlng and how it is normally used to end the edit session.

Here's a workaround for the bug and my take on how to create popup editors. Usual caveats apply.

Download Source
Run Example

August 04, 2008

DataGrid ItemEditor with Two Input Fields

Several folks have been asking about how to have a DataGrid ItemEditor with two input fields (say you want to separately edit first name and last name or something like that).

It's a bit tricky because of some missing pieces in the underlying Flash focus APIs and because of how Focus events work. Here is my take on how to do it. Usual caveats apply (i.e, code is not supported and may have bugs etc).

Download Source
Run Example