The more interesting question is why the second one isn't.  Because all
of your references to the module are in temporary local variables, as
soon as you exit the click handler, the module is available for garbage
collection, and in the first case it got collected and the second it
didn't, but usually a module's arrival forces a gc.

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Christopher DUPONT
Sent: Wednesday, August 06, 2008 10:34 AM
To: [email protected]
Subject: [flexcoders] Flex Module issue



Why child is null in the first case ?

private function btnStatsClickHandler(event:Event):void
        {
            var module:IModuleInfo =
ModuleManager.getModule("com/test/module/pictureviewer/PictureViewer.swf
");
            
            module.addEventListener(ModuleEvent.READY, 
                function(event:ModuleEvent):void {
                    var child:* = module.factory.create();
                    trace("child: " + child);
            &n! bsp;   });
                
            module.load();
        }

RESULT:
[SWF]
D:\flexworkspace\test\bin\com\test\module\pictureviewer\PictureViewer.sw
f - 50 612 bytes after decompression
child: null

private function btnStatsClickHandler(event:Event):void
        {
            var module:IModuleInfo =
ModuleManager.getModule("com/test/module/pictureviewer/PictureViewer.swf
");
            
            module.addEventListener(ModuleEvent.READY, 
                function(event:ModuleEv! ent):void {
        &nbs! p;           var child:PictureViewer =
module.factory.create() as PictureViewer;
                    trace("child: " + child);
                });
                
            module.load();
        }

RESULT:
[SWF]
D:\flexworkspace\test\bin\com\test\module\pictureviewer\PictureViewer.sw
f - 50 612 bytes after decompression
child: PictureViewer608 

 

Reply via email to