I'm banging my head for 2 days now with this and finally gave up.
I have an application (just a bunch of normal mxml with puremvc) and I'm loading another application into it (mxml with puremvc like the first one). All the flex, puremvc multicore, pipes libraries are externals (not compiled into the code)
Whenever I load the 2nd into the first I want to raise an event in order to connect the 2 through pipes.
And that's where the problem comes in, when this function is called finally then the module is null!public function connectModule( module:IPipeAwareModule):void
junction.registerPipe( ConstPipe.PIPE_SHELL_TO_MODULE,Junction.OUTPUT,new TeeSplit() );
junction.registerPipe( ConstPipe.PIPE_MODULE_TO_SHELL,Junction.INPUT,new TeeMerge() );
junction.addPipeListener( ConstPipe.PIPE_MODULE_TO_SHELL,this,handlePipeMessage );
var moduleToShell: Pipe = new Pipe();
module.acceptOutputPipe( ConstPipe.PIPE_MODULE_TO_SHELL, moduleToShell );
var shellInFitting: TeeMerge = junction.retrievePipe( ConstPipe.PIPE_MODULE_TO_SHELL ) as TeeMerge;
shellInFitting.connectInput( moduleToShell );
var shellToModule: Pipe = new Pipe();
module.acceptInputPipe( ConstPipe.PIPE_SHELL_TO_MODULE, shellToModule );
Here are some versions I tried with:
protected var loader:SWFLoader;
public function loadApp():void
loader = new SWFLoader();
var apploc:String = "XXXAPP.swf";
var context:LoaderContext = new LoaderContext();
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
loader.loaderContext = context;
loader.trustContent = true;
loader.source = apploc;
private function completeHandler(event:Event):void
var ev:MyEvent = new MyEvent(ELOADED);
ev.data = loader.loaderInfo.applicationDomain.getDefinition("XXXAPP") as Class;
ev.data = loader.content as IPipeAwareModule;
ev.data = (loader.content as SystemManager).application;
ev.data = loader.content as SystemManager).application as IPipeAwareModule
//And i can continue with all the variations of the above ...
// None of those are working when I dispatch the event the module is always null in connectModule
I've also tried with the Loader and ModuleLoader classes ... without sucess.
The application is loaded, appears in the GUI and works correctly inside the shell application.
The problem is that when the event is dispatched (in the completeHandler) and finally the connectModule function is called the module parameter (module = ev.data) is allways null.
I tried to listen after the complete event for the FlexEvent.INITIALIZE event, but that was not dispatched... I suspect I should listen to some initialize event ...
On the other hand if from the module application I call manually the connectModule (in the shell application) it allways works
But that's just disgusting from a programming practice perspective isn't it?