Application property preloader

Source: Internet
Author: User

 

<Mx: Application xmlns: mx = "http://www.adobe.com/2006/mxml"
preloader="mycomponents.mydownloadbar"> // Here mycomponents. mydownloadbar is
The class that you want to embody. At the same time, the following is not to show the load entries
<Mx: Application xmlns: mx = "http://www.adobe.com/2006/mxml"
UsePreloader = "false"> //The usePreloader attribute indicates whether to use the load entry.

Code for generating basic load entries:

Package myComponents {import mx. preloaders. *; import flash. events. progressEvent; public class DownloadProgressBarSubClassMin extends DownloadProgressBar {public function DownloadProgressBarSubClassMin () {super (); // set the downloadingLabel = "Downloading app... "// set the prompt text for the preliminary trial
InitializingLabel = "Initializing app..." // sets the minimum display time.
Minimum_display_time = 2000;} // overwrite the display property to true, so that the load entries are displayed // during initialization. override protected function showdisplayforinit (elapsedtime: int, Count: INT): Boolean {return true;} // The download status shows that the attributes are true, so that loading entries are displayed during the download process. override protected function showdisplayfordownloading (elapsedtime: int, event: progressevent): Boolean {return true ;}}// load custom load entries
<?xml version="1.0"?> <!-- containers/application/MainDPBMin.mxml --><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"     preloader="myComponents.DownloadProgressBarSubClassMin">    <mx:Button/>
</mx:Application>
 
Advanced-this is not what I want. I want to load an animation of my own.
// The following code can satisfy us (of course, flexible use can lead to more beautiful Loading records)

Package mycomponents
{
Import flash. display. Sprite;
Import MX. preloaders. ipreloaderdisplay;
Import flash. Events. event;
Import flash. Events. progressevent;
Import flash. Events. timerevent;
Import flash.net. URLRequest;
Import flash. utils. timer;
Import MX. Events. flexevent;
Public class mydownloadprogressbarswf extends Sprite
Implements ipreloaderdisplay
{
// Define a container to load SWF.
Private var dpbimagecontrol: Flash. display. loader;
Public Function mydownloadprogressbarswf (){
Super ();
}
// Specify event listening.
Public function set preloader (preloader: Sprite): void {
// Listen for the relevant events
Preloader. addEventListener (
ProgressEvent. PROGRESS, handleProgress );
Preloader. addEventListener (
Event. COMPLETE, handleComplete );
Preloader. addEventListener (
FlexEvent. INIT_PROGRESS, handleInitProgress );
Preloader. addeventlistener (
Flexevent. init_complete, handleinitcomplete );
}
// Initialize the load container event to redefine the ipreloaderdisplay. initialize () event
Public Function initialize (): void {
Dpbimagecontrol = new flash. display. loader ();
Dpbimagecontrol. contentloaderinfo. addeventlistener (
Event. Complete, loader_completehandler );
Dpbimagecontrol. Load (New URLRequest ("assets/dpbswf.swf "));
}

// After SWF is read, define the size of the SWF container to be read.
Private function loader_completehandler (Event: Event): void
{
Addchild (dpbimagecontrol );
Dpbimagecontrol. width = 50;
Dpbimagecontrol. Height = 50;
Dpbimagecontrol. x = 100;
Dpbimagecontrol. Y = 100;
}
// Define an empty event listener.
Private function handleprogress (Event: progressevent): void {
}
Private function handlecomplete (Event: Event): void {
}
Private function handleinitprogress (Event: Event): void {
}
Private function handleinitcomplete (Event: Event): void {
VaR Timer: timer = new timer (2000,1 );
Timer. addeventlistener (timerevent. Timer, dispatchcomplete );
Timer. Start ();
}
Private function dispatchcomplete (Event: timerevent): void {
Dispatchevent (new event (event. Complete ));
}

// Execute the ipreloaderdisplay class Interface
Public Function get backgroundcolor (): uint {
Return 0;
}
Public function set backgroundColor (value: uint): void {
}
Public function get backgroundAlpha (): Number {
Return 0;
}
Public function set backgroundAlpha (value: Number): void {
}
Public function get backgroundImage (): Object {
Return undefined;
}
Public Function set backgroundimage (value: Object): void {
}
Public Function get backgroundsize (): String {
Return "";
}
Public Function set backgroundsize (value: string): void {
}
Public Function get stagewidth (): number {
Return 200;
}
Public Function set stagewidth (value: Number): void {
}
Public Function get stageheight (): number {
Return 200;
}
Public Function set stageheight (value: Number): void {
}
}

}

Load the Loading Control Using mxml

<? XML version = "1.0"?>
<! -- Containers/application/maindpbmin. mxml -->
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml"
Preloader = "mycomponents. mydownloadprogressbarswf">

<Mx: Button/>
<Mx: TextInput text = "sub class min"/>
</Mx: Application>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.