Flex optimization when using multiple modules

I have a Flex application where load time is extremely important (consumer site). I want to get something on the screen, and then allow the loading of additional modules as needed.

The problem I am facing is that the total amount of all modules is much larger than if I included all the components in a single .swf file.

This is pretty obvious. For example, the classes required to access a web service seem to be approximately 100 kb. If I do not use these classes in my main.swf, then they will be included in the EVERY module that uses them. So, if I have 5 modules, then the extra 500 kB is wasted.

In theory, I want 3 levels

main.swf - the minimum possible layout / style / font / type of the common.swf framework - additional classes required by module 1 + module 2 (for example, web services) module1.swf - module 1 on the site module2.swf - module 2 on the site

I do not know if this is possible.

I am wondering if I can upload swz / swf files for parts of the framework instead of the whole structure.

I really need to get my main application size up to 200 KB. It increases to 450KB when I add web services and basic datagrid features.

Any lessons learned would be appreciated.

+3
source share
5 answers

I know that this was some time ago, but I decided that I would send a different answer if someone is still looking for an answer to this.

Flex , , . , .

mxmlc, :

mxmlc -link-report=MyAppReport.xml MyApp.mxml

mxmlc -load-externs=MyAppReport.xml MyModule.mxml

swf ( Flex Framework) 21k. (), , , .

, ( mxmlc Path, . → → → , Edit the Path System , mxmlc ( ):

cd C:\Projects\MyProject\Develop\Modules
mxmlc -link-report=MyAppReport.xml C:\Projects\MyProject\Develop\Source\Main.mxml
mxmlc -load-externs=MyAppReport.xml MyModule.mxml
move /Y MyModule.swf ..\Runtime\Modules

: http://livedocs.adobe.com/flex/3/html/help.html?content=modular_4.html

, !

+3

Flex - , . , swz . Adobe Devnet Flex Flash Player, .

, , , , . , , . , IApplicationModule, .

SWF , ApplicationDomain

( , , , Flex)


private function loadContent(path:String):void 
{
   var contentLoader:Loader = new Loader();
   contentLoader.contentLoaderInfo.addEventListener(
      Event.COMPLETE,
      loadContent_onComplete);
   contentLoader.load(new URLRequest(path));
}


private function loadContent_onComplete (event:Event):void
{  
   var content:DisplayObject = event.target.content;

   if(content is IFlexModuleFactory) 
   {
      var content_onReady:Function = function (event:Event):void 
      {   
         var factory:IFlexModuleFactory = content as IFlexModuleFactory;
         var info:Object = factory.info();
         var instanceClass:Class = info.currentDomain.getDefinition(
            info.mainClassName) as Class;

         addChild (new instanceClass ());
      }

      content.addEventListener ("ready", content_onReady);

   } 
   else
   {
      addChild (content);  
   }
}
+1

, swf. :

  • ( ) .
  • .
+1

You can study the ModuleLoader class , perhaps you can load your main material into the first 200 kilobytes, and then load the rest when and if it was needed.

It is also worth remembering that any SWC that you use is injected at compile time, while any SWF is loaded at runtime.

0
source

Source: https://habr.com/ru/post/1698062/


All Articles