Module switching: How to Implement Loading

Source: Internet
Author: User
Flex is not that troublesome.

  1. <Mx: progressbar source = "msgeditor"/>
  2. <Mx: moduleloader id = "msgeditor" url = "View/contactpanel.swf"/>

Copy code

You can.

How to use code, flex has modulemanager import MX. Events. moduleevent;
Import MX. modules. modulemanager;
Import MX. modules. moduleloader;
Import MX. modules. imoduleinfo;

Protected VaR _ moduleinfo: imoduleinfo; Public Function Init (): void
{

_ Moduleinfo = modulemanager. getmodule ("testm.swf ");
// Add some listeners
_ Moduleinfo. addeventlistener (moduleevent. Ready, onmoduleready );
_ Moduleinfo. addeventlistener (moduleevent. setup, onmodulesetup );
_ Moduleinfo. addeventlistener (moduleevent. Unload, onmoduleunload );
_ Moduleinfo. addeventlistener (moduleevent. Progress, onmoduleprogress );


_ Moduleinfo. Load (); // var M1: moduleloader = new moduleloader ();
// M1.url = "tew..swf"; // The URL points to modone. mxml
// M1.loadmodule (); // sends a command to call the module

// This. addchild (M1 );
// URL = "tew..swf" width = "800" Height = "600"

}


Public Function onmoduleready (E: moduleevent)
{
Trace ("ready ");

// Cast the currenttarget
VaR moduleinfo: imoduleinfo = E. currenttarget as imoduleinfo;
// Add an instance of the module's class to
// Display list.
Trace ("calling imoduleinfo. Factory. Create ()");
This. addchild (moduleinfo. Factory. Create () as testm );
Trace ("somemodule instance created and added to display List ");
}

Public Function onmodulesetup (EVT: moduleevent)
{
Trace ("setup ");
}

Public Function onmoduleunload (EVT: moduleevent)
{
Trace ("Unload ");
}

Public Function onmoduleprogress (Event: moduleevent)
{
// Trace ("progress ");
Trace ("moduleevent. Progress completed ed:" + event. bytesloaded + "of" + event. bytestotal + "loaded .");
}

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.