Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Module hell. ModuleEvent won't fire.  (Read 9445 times)
deltajam
Courseware Beta
Full Member
***
Posts: 25


View Profile Email
« 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?
Logged
deltajam
Courseware Beta
Full Member
***
Posts: 25


View Profile Email
« Reply #1 on: March 04, 2009, 05:07:39 »

figured it out.  This post:
http://www.joshuaostrom.com/2008/08/14/flex-modules-watch-your-scope/

Lesson learned.  Locally scoped variables get trashed quick by the garbage collection.
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #2 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.
Logged
Pages: [1]
Print