Setting or clearing the application background image in Flex

The following example shows how you can remove the default gradient background image for a Flex application by setting the backgroundImage style.

Full code after the jump.


<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<mx:Application xmlns:mx=""


            private var defaultBackgroundImage:Class;

            private function init():void {
                defaultBackgroundImage = Application.application.getStyle("backgroundImage");

            private function toggleButtonBar_itemClick(evt:ItemClickEvent):void {

    <mx:Array id="arr">
        <mx:Object label="default" data="{defaultBackgroundImage}" />
        <mx:Object label="null" data="{null}" />

    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain">
            <mx:FormItem label="backgroundImage:">
                <mx:ToggleButtonBar id="toggleButtonBar"
                        itemClick="toggleButtonBar_itemClick(event);" />


View source is enabled in the following example.

You can also set the backgroundImage style in an external .CSS file, or <mx:Style /> block, as shown in the following snippet:

    Application {
        backgroundImage: ClassReference(null);

Or, you can set the backgroundImage style in MXML, as shown in the following snippet:

<mx:Application xmlns:mx=""

5 thoughts on “Setting or clearing the application background image in Flex

  1. I am loading a Flex app into a Flash app (I know, don’t ask). The Flex app is made transparent (see example above). Still the Flex app will take over the mouse if it hovers over the loaded FlexApp.swf. Can this be prevented or is this inherent in the way the Flex framework has been set up?

  2. previous didnt come out

    add this to your application starting tag

    paddingBottom=”0″ paddingLeft=”0″ paddingRight=”0″ paddingTop=”0″

    and the part you’re trying to hide will be completely gone, no need for the complicated response

  3. How i can make magmatic lasso tool to remove background color. And then crop that image, and need to save .png in flex. Please provide me tutorial or code.

Comments are closed.