Adding a drop shadow to a custom chrome window in AIR 2

I've updated the example and tested it against Flash Builder 4 and AIR 2.0 SDK.

Problem

You want to add a drop shadow to the border of a window that has custom chrome applied.

Solution

Pass a DropShadowFilter instance to the filters Array of the NativeWindow instance, or set the dropShadowEnabled and dropShadowColor styles.

Detailed explanation

A window that has custom chrome applied can have a drop shadow around its borders. This window can be your main application window or any other window in the application. When you want to add a shadow around your main application window, make sure to set the transparency of this window using the systemChrome and transparent attributes in the application descriptor file:

<systemChrome>none</systemChrome>

<transparent>true</transparent>

You can then add a drop shadow to your window in two ways. The first way is to instantiate a DropShadowFilter (a subclass of the BitmapFilter class) object and set the properties you want for the drop shadow. Every DisplayObject has a filters Array property where you can store BitmapFilter instances you want to use on that DisplayObject. For the DropShadowFilter, you can define many properties, such as color, alpha, blurX, blurY, distance, and angle, to customize the look and feel of your drop shadow.The following example is a basic AIR application with custom chrome applied (Figure 20-1). Actually, the chrome consists of just three Canvas components from the Flex Framework.

The drop shadow is configured as follows:

shadowFilter = new DropShadowFilter();

shadowFilter.color = 0xFF0000;

shadowFilter.alpha = 0.75;

shadowFilter.blurX = 5;

shadowFilter.blurY = 5;

shadowFilter.distance = 5;

shadowFilter.angle = 90;

To cast the drop shadow on the window's transparent background, assign the shadowFilter instance to the filters Array of the WindowedApplication instance. In this example, the keyword refers to the WindowedApplication instance: