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:
Create a class that subclasses
mx.preloaders.DownloadProgressBaror subclassesSpriteand implements themx.preloaders.IPreloaderDisplayinterface.Set the
preloaderproperty of theApplicationobject 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. Then ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access