Jeff,
Not sure if you have an answer yet or not but I would add to it some notes we
have seen. We have created several modules (four of them) and try to load them
into our main app. All modules and the main app are compiled with the same sdk
and on the same machine, all in Flash Builder 4. The problem is each time we
load a module in, the screens greys out for minutes before responding and
sometimes the modules never load, in fact we get errors sometimes. You re-run
the program and you get different results. Essentially it appears that Flash
builder and modules are currently flakey - with not help being discovered on
the internet so far. I have pinged this list before and unless we get the
attention of someone like Chet or Alex or any of the other Adobe guys on this,
I fear it will be quite sometime before we seen anything useful. I have tried
things like using simple mxml ModuleLoader tab and the below code I found on
the internet: (It works sometimes for us, and seems well written.)
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- modules/CustomModuleLoader.mxml -->
<mx:ModuleLoader
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns="*"
creationComplete="init()" horizontalAlign="center"
verticalAlign="middle"
horizontalCenter="0" verticalCenter="-2">
<fx:Script>
<![CDATA[
public function init():void {
addEventListener("urlChanged", onUrlChanged);
addEventListener("loading", onLoading);
addEventListener("progress", onProgress);
addEventListener("setup", onSetup);
addEventListener("ready", onReady);
addEventListener("error", onError);
addEventListener("unload", onUnload);
standin = panel;
//removeChild(standin);
addChild(standin);
}
public function onUrlChanged(event:Event):void {
if (url == null) {
if (contains(standin))
removeChild(standin);
} else {
if (!contains(standin))
addChild(standin);
}
progress.indeterminate=true;
unload.enabled=false;
reload.enabled=false;
}
public function onLoading(event:Event):void {
progress.label="Loading module " + url;
if (!contains(standin))
addChild(standin);
progress.indeterminate=true;
unload.enabled=false;
reload.enabled=false;
}
public function onProgress(event:Event):void {
progress.label="Loaded %1 of %2 bytes...";
progress.indeterminate=false;
unload.enabled=true;
reload.enabled=false;
}
public function onSetup(event:Event):void {
progress.label="Module " + url + "
initialized!";
progress.indeterminate=false;
unload.enabled=true;
reload.enabled=true;
}
public function onReady(event:Event):void {
progress.label="Module " + url + " successfully
loaded!";
unload.enabled=true;
reload.enabled=true;
if (contains(standin))
removeChild(standin);
}
public function onError(event:Event):void {
progress.label="Error loading module " + url;
unload.enabled=false;
reload.enabled=true;
}
public function onUnload(event:Event):void {
if (url == null) {
if (contains(standin))
removeChild(standin);
} else {
if (!contains(standin))
addChild(standin);
}
progress.indeterminate=true;
//progress.label="Module " + url + " was
unloaded!";
progress.label="Module was unloaded!";
unload.enabled=false;
reload.enabled=true;
}
public var standin:DisplayObject;
]]>
</fx:Script>
<s:Panel id="panel" width="50%" title="Module Loader Status &
Operations" verticalCenter="-2" horizontalCenter="0">
<s:layout>
<s:VerticalLayout horizontalAlign="center"
verticalAlign="middle"/>
</s:layout>
<mx:ProgressBar width="90%" id="progress" source="{this}"/>
<s:HGroup width="100%" paddingLeft="15">
<s:Button id="unload" label="Unload Module"
click="unloadModule()"/>
<s:Button id="reload" label="Reload Module"
click="unloadModule();loadModule()"/>
</s:HGroup>
</s:Panel>
</mx:ModuleLoader>