Hi,

I might be missing something, but AFAICT, even if all of that works perfectly, 
you still don't know if your code has caused some Flex framework code to attach 
a listener to the stage, a Timer, a network class, etc.  IOW, I think you can 
run code like:

import mx.controls.ComboBox;
var cb:ComboBox = new ComboBox();
addChild(cb);
trace(cb.dropDown);

IIRC, simple code like this can pin a module into memory, and your clean up 
code won't catch it.

HTH,
-Alex

On 5/24/18, 1:30 PM, "aceinc" <pa...@compuace.com> wrote:

    Alex, I have implemented the code to destroy event listeners in all of my
    widgets, as well as the calling class. The calling class is called from the
    root as a module. Before unloading the module I do the following to try and
    remove all event listeners;
    
    private function clearModuleEvents(mdlModule:ModuleLoader):void
    {
        trace('Starting clearModuleEvents')
        for(var idx:int = mdlModule.numChildren - 1; idx >= 0; idx--)
        {
                trace('idx=' + idx + 'isContainer(objChild)=' 
+isContainer(objChild) +
    'isContainer(mdlModule.getChildAt(idx))=' +
    isContainer(mdlModule.getChildAt(idx)));
            var objChild:DisplayObject = mdlModule.getChildAt(idx);
            trace('flash.utils.getQualifiedClassName(objChild)=' +
    flash.utils.getQualifiedClassName(objChild)); 
            var childContainer:DisplayObjectContainer = objChild as
    DisplayObjectContainer;
            clearChildEvents(childContainer);
                if ("clearEvents" in objChild)
                {
                        var fncClearEvents:Function = objChild["clearEvents"];
                if (objChild.hasOwnProperty('id')) trace('Clearing Events 
in==>>' +
    objChild['id']);
                        fncClearEvents();
                        fncClearEvents = null;
                }
                if ("dataProvider" in objChild)objChild["dataProvider"] = null;
                if ("selectedIndex" in objChild)objChild["selectedIndex"] = -1;
                if ("selectedItem" in objChild)objChild["selectedItem"] = null;
                if ("value" in objChild)objChild["value"] = null;
        }
        objChild = null;
        trace('Finished clearModuleEvents')
    }
    
    private function clearChildEvents(dpsContainer:DisplayObjectContainer):void
    {
        for(var idx:int = dpsContainer.numChildren - 1; idx >= 0; idx--)
        {
            var objChild:DisplayObject = dpsContainer.getChildAt(idx);
                if (isContainer(objChild))
                {
                var childContainer:DisplayObjectContainer = objChild as
    DisplayObjectContainer;
                clearChildEvents(childContainer);
                }
                if ("killMe" in objChild)
                {
                        var fncKillMe:Function = objChild["killMe"];
                if (objChild.hasOwnProperty('id')) trace('Killing Events 
in==>>' +
    objChild['id']);
                        fncKillMe();
                        fncKillMe = null;
                }
                else if ("clearEvents" in objChild)
                {
                        var fncClearEvents:Function = objChild["clearEvents"];
                if (objChild.hasOwnProperty('id')) trace('Clearing Events 
in==>>' +
    objChild['id']);
                        fncClearEvents();
                        fncClearEvents = null;
                }
                if ("dataProvider" in objChild)objChild["dataProvider"] = null;
                if ("selectedIndex" in objChild)objChild["selectedIndex"] = -1;
                if ("selectedItem" in objChild)objChild["selectedItem"] = null;
    //          if ("value" in objChild)objChild["value"] = null;
                objChild = null;
        }
    }
    
    
    
    
    
    --
    Sent from: 
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&data=02%7C01%7Caharui%40adobe.com%7C110b4012ca394ee4b27b08d5c1b53108%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636627906328800733&sdata=DIbMjs4iq5lHDN1NDhD8dKXQI9vdXxp71xlu4VcW9ys%3D&reserved=0
    

Reply via email to