Get the App
SLTechnology News&Howtos  ›  Development  › 

Why use Flex Modularization

Shulou Source: shulou.com Published: 2022-06-02 06:47:03 09月24日 Update

This article will explain in detail why to use Flex modularization, the editor thinks it is very practical, so share it for you to do a reference, I hope you can get something after reading this article.

1. Why Flex Modularization

Flex modularization provides separation of application code into different swf files to reduce download time and file size. The benefits of using Modules are:

1. You don't need to download modules immediately when the main application starts. The application loads and unloads modules as required.

two。 Because each modules is independent of the other application modules, when you need to change a modules, you only need to recompile the modules instead of the entire application.

Flex modularization can create Flex modular applications is an important aspect of improving the performance of the Flex framework, providing more ability to control download time and file size. With modules, you can separate application code based on which can be loaded independently and which can be used by other programs.

two。 How to modularize Flex

2.1 create a module

Mxml-based module, right-click on your project-> new- > mxmlModule

As-based module

Package {importmx.modules.Module; publicclassGeneralextendsModule {publicfunctionGeneral () {super ();}

Load module in 2.2Flex modularization

2.2.1 loading using ModuleLoader

2.2.2 loading using ModuleManager

PrivatefunctioncreationHandler (): void {_ moduleInfo= ModuleManager.getModule ('ContactList.swf'); _ moduleInfo.addEventListener (ModuleEvent.READY, moduleLoadHandler); _ moduleInfo.load ();} PrivatefunctionmoduleLoadHandler (evt:ModuleEvent): void {canvas.addChild (_ moduleInfo.factory.create () as DisplayObject);}

2.2.3 create a pop-up module

Vargeneral:ModuleLoader general=ModuleLoader (mx.managers.PopUpManager. CreatePopUp (this,ModuleLoader)); general.url= "General.swf"

Note: when creating a pop-up module, there is sometimes an error that cannot convert mx.managers::PopUpManagerImpl@bba9941 to mx.managers.IPopUpManager, so we need to introduce it into the main program.

Importmx.managers.IPopUpManager; privatevaripopUp:IPopUpManager on "Why to use Flex modularization" this article to share here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Tags: Modules programs applications applications files more articles code size time independence difference good practical important main program content benefits engineering performance Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Information Microsoft MySQL NVidia