The main class of the Flex4.6 program is actually a subclass of Systemmanager. Systemmanager creates the Preloader object and then calls the Initialize method of the Preloader object, which has the following signature
public function initialize (showdisplay:boolean, displayClassName:Class, backgroundColor:uint, backgroundAlpha:Number, backgroundImage:Object, &Nbsp; backgroundsize:string , displayWidth:Number, displayHeight:Number, libs:Array = null, sizes:Array = null, rslList:Array = null, resourceModuleURLs:Array = null, applicationdomain:applicationdomain = null): void
Showdisplay will pass in The Application.usepreloader property, Displayclassname passes in the Application.preloader property (the class object obtained from the name string), and the Backgroundxxx attribute corresponds to the application BAC The Kgroundxxx property, Displaywidth and Displayheight, will pass through the stage size.
The Preloader.initialize method fragment is as follows
if (showdisplay) { displayclass = new displayclassname (); // Listen for when the displayClass no longer needs to be on the stage Displayclass.addeventlistener (event.complete, Displayclasscompletehandler); // add the display class as a child of the preloAder addchild (DisplayObject ( Displayclass)); displayClass.backgroundColor = backgroundColor; displayClass.backgroundAlpha = backgroundAlpha; displayClass.backgroundImage = backgroundimage; displayclass.backgroundsize = backgroundsize; displayClass.stageWidth = displayWidth; displayclass.stageheight = displayheight; Displayclass.initialize (); displayclass.preloader = this; .................. }
If application.usepreloader==true, a download progress bar is created, an instance that implements the Ipreloaderdisplay interface (and is an instance of the Displayobject subclass, which is a display object). Then set backgroundxxx,stagewidth and Stageheight, invoke the Initialize method of the progress bar instance, set the Preloader property, and pass the preloader itself into the progress bar instance.
Typically, when you set the Preloader property, you listen for 7 events for the Preloader instance, as shown in Sparkdownloadprogressbar
Public function set Preloader (value:sprite): void{_preloader = value; Value.addeventlistener (progressevent.progress, Progresshandler); Value.addeventlistener (Event.complete, Completehandler); Value.addeventlistener (rslevent.rsl_progress, Rslprogresshandler); Value.addeventlistener (Rslevent.rsl_complete, Rslcompletehandler); Value.addeventlistener (Rslevent.rsl_error, Rslerrorhandler); Value.addeventlistener (flexevent.init_progress, Initprogresshandler); Value.addeventlistener (Flexevent.init_complete, Initcompletehandler);}
Progressevent.progress Event Response Program Download progress, the Event.complete event is dispatched when the program download is complete, rslevent is the associated event of the shared library when loading the payload. Flexevent.init_progress dispatched when the program download is complete to start initializing the Preloader dispatch Flexevent.init_complete event, which means that the application has been downloaded and initialized. You need to download the progress bar Ipreloaderdisplay instance to schedule a Event.complete event to notify Preloader to delete the progress bar, showing application
So when customizing the Flex 4.6 program Download progress bar, you need to first define a Sprite class that implements the Ipreloaderdisplay interface. Processing Preloader 7 events, in the Progressevent.progress event scheduling is to change the appearance of the progress bar, after flexevent.init_complete scheduling, you can do some additional processing, such as playing animation or sound, and finally do not forget , the Ipreloaderdisplay progress bar object must dispatch a Event.complete event that notifies Preloader to remove the progress bar, showing application.
Flex 4.6 Download progress bar Ipreloaderdisplay life cycle