code_junkie

Optimizing Flex when multiple modules are used

Nov 11th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. mxmlc -link-report=MyAppReport.xml MyApp.mxml
  2.  
  3. mxmlc -load-externs=MyAppReport.xml MyModule.mxml
  4.  
  5. cd C:ProjectsMyProjectDevelopModules
  6. mxmlc -link-report=MyAppReport.xml C:ProjectsMyProjectDevelopSourceMain.mxml
  7. mxmlc -load-externs=MyAppReport.xml MyModule.mxml
  8. move /Y MyModule.swf ..RuntimeModules
  9.  
  10. private function loadContent(path:String):void
  11. {
  12. var contentLoader:Loader = new Loader();
  13. contentLoader.contentLoaderInfo.addEventListener(
  14. Event.COMPLETE,
  15. loadContent_onComplete);
  16. contentLoader.load(new URLRequest(path));
  17. }
  18.  
  19.  
  20. private function loadContent_onComplete (event:Event):void
  21. {
  22. var content:DisplayObject = event.target.content;
  23.  
  24. if(content is IFlexModuleFactory)
  25. {
  26. var content_onReady:Function = function (event:Event):void
  27. {
  28. var factory:IFlexModuleFactory = content as IFlexModuleFactory;
  29. var info:Object = factory.info();
  30. var instanceClass:Class = info.currentDomain.getDefinition(
  31. info.mainClassName) as Class;
  32.  
  33. addChild (new instanceClass ());
  34. }
  35.  
  36. content.addEventListener ("ready", content_onReady);
  37.  
  38. }
  39. else
  40. {
  41. addChild (content);
  42. }
  43. }
Add Comment
Please, Sign In to add comment