Hi there,
I have this code which I have used for a long time in my AIR Apps which have a few modules only, but I wanted to test it and maybe use it also now in my other Flex Apps, but here I have many modules and I can't find the right approach to converting this code into something like a Switch / case to be able to cut down on code lines and have this working effectively there also !
Any help would be appreciated I have tried a few things yet always seem to get stuck.
The code I have used until now and which worked very well in AIR Apps:
The code for the next module would be more or less the same:Code:<mx:Script> <![CDATA[ protected function modIntro_activateHandler(event:Event):void { var loaded:Boolean; var childDomain:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain); if (loaded) unload(); else load(); function load():void { loaded = true; modIntroStep.applicationDomain = childDomain; modIntroStep.loadModule("StepIntroGeneralENE.swf"); loaded = false; childDomain = null; } function unload():void { loaded = false; modIntroStep.applicationDomain = null; modIntroStep.unloadModule(); /* loaded = false; */ childDomain = null; modIntroStep.deleteReferenceOnParentDocument(this); startGCCycle(); } } ]]> </mx:Script> <mx:ModuleLoader id="modIntroStep"/>
Code:<mx:Script> <![CDATA[ protected function modStep1_activateHandler(event:Event):void { var loaded:Boolean; var childDomain:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain); if (loaded) unload(); else load(); function load():void { loaded = true; modStep1.applicationDomain = childDomain; modStep1.loadModule("StepIntroGeneralDEE.swf"); loaded = false; childDomain = null; } function unload():void { loaded = false; modStep1.applicationDomain = null; modStep1.unloadModule(); /* loaded = false; */ childDomain = null; modStep1.deleteReferenceOnParentDocument(this); startGCCycle(); } } ]]> </mx:Script> <mx:ModuleLoader id="modStep1"/>




Reply With Quote