O'Reilly logo

Programming Flex 2 by Joey Lott, Chafic Kazoun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Customizing the Preloader

By default, all Flex applications use a standard preloader progress bar screen while the application itself is downloading. If you choose, you can create a custom preloader screen. This is possible and relatively simple to accomplish. There are two steps:

  1. Create a class that subclasses mx.preloaders.DownloadProgressBar or subclasses Sprite and implements the mx.preloaders.IPreloaderDisplay interface.

  2. Set the preloader property of the Application object to the path to the class from the preceding step.

The first of these two steps is the more complicated of the two, but it is still reasonably trivial. You have two options: either subclass mx.preloaders.DownloadProgressBar or create a Sprite subclass that also implements mx.preloaders.IPreloader. Let's look at the DownloadProgressBar subclass first.

Technically you can subclass DownloadProgressBar as an all-purpose solution. However, from an academic standpoint, it's better to subclass DownloadProgressBar only when you intend to customize the default preloader screen. When subclassing DownloadProgressBar, you'll want to ensure that you always called the super constructor from the constructor of the subclass:

package com.oreilly.programmingflex.preloader {

    import mx.preloaders.DownloadProgressBar;

    public class CustomPreloaderSubclass extends DownloadProgressBar {

        public function CustomPreloaderSubclass(  ) {
            super(  );
        }

    }
}

The super constructor ensures that the proper event handlers are configured for the class. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required