PureMVC Architects Lounge

PureMVC Manifold => MultiCore Version => Topic started by: deltajam on March 04, 2009, 04:38:03



Title: Module hell. ModuleEvent won't fire.
Post by: deltajam on March 04, 2009, 04:38:03
I can't figure this out.  I'm going to rip my hair out.  My module is loading with one of the Fabrication examples I modified.  "loading"

However, I can't add the module to the display list, because the ModuleEvent class won't fire anything back! 

:
trace( moduleVO.url );
var moduleLoader:FlexModuleLoader = new FlexModuleLoader();

moduleLoader.id = moduleVO.getElementID();
moduleLoader.url = moduleVO.url;
moduleLoader.router = applicationRouter;

if (moduleVO.moduleGroup != null)
{
moduleLoader.moduleGroup = moduleVO.moduleGroup;
moduleLoader.defaultRoute  = moduleVO.moduleGroup;
}
else
{
moduleLoader.defaultRouteAddress = applicationAddress;
}

moduleLoader.addEventListener(FabricatorEvent.FABRICATION_CREATED, moduleCreated);
moduleLoader.addEventListener(FabricatorEvent.FABRICATION_REMOVED, moduleRemoved);
moduleLoader.addEventListener(ModuleEvent.READY, moduleReadyListener);
trace( moduleLoader );
moduleLoader.loadModule();

My module loads, because my console says it does ... but I can never seem make it to this function:

:
private function moduleReadyListener( event:ModuleEvent ):void
{
trace( "module ready!" );
event.target.removeEventListener(ModuleEvent.READY, moduleReadyListener);
moduleContainer.addChild(event.target as DisplayObject);
}

any sugestions.  I feel like this is something really simple.  Why wouldn't the eventListener be ... listening?


Title: Re: Module hell. ModuleEvent won't fire.
Post by: deltajam on March 04, 2009, 05:07:39
figured it out.  This post:
http://www.joshuaostrom.com/2008/08/14/flex-modules-watch-your-scope/ (http://www.joshuaostrom.com/2008/08/14/flex-modules-watch-your-scope/)

Lesson learned.  Locally scoped variables get trashed quick by the garbage collection.


Title: Re: Module hell. ModuleEvent won't fire.
Post by: Jason MacDonald on March 04, 2009, 06:58:02
Yup, I discovered the same a while back. Only my issue was with the Loader class in Flash, rather than Flex.