Right - the listener would have to be added to the stage, with a
callback on the pop up. The point is that, even without such a
listener, things eventually grow (albeit slowly).
Another interesting (and possibly related) case is when you add a weak
reference to track if something still exists. When I add and remove
dialogs, the first one seems to stay in existence forever, no matter
what (though the others go away just fine). This even happens if I
don't add it to the stage at all. All that needs to happen is the
TitleWindow must have a child, and I get this behavior.
-- CODE EXAMPLE ---
--- MyApp.mxml ---
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:local="*"
layout="vertical">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import flash.utils.setTimeout;
public var popUps:Array = []
public function addObject():void
{
var dialog:LoginDialog = new LoginDialog();
addEventListener("enterFrame",dialog.sayHi,false,0,true);
popUps.push(dialog);
trace("adding "+dialog);
}
public function removeAllObjects():void
{
while(popUps.length>0){
trace("removing "+popUps.pop());
}
}
]]>
</mx:Script>
<mx:Button label="add" click="addObject()" />
<mx:Button label="remove" click="removeAllObjects()" />
</mx:Application>
--- LoginDialog.mxml ---
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" title="Login" >
<mx:Script>
<![CDATA[
import mx.core.Application;
import mx.binding.utils.ChangeWatcher;
public var counter:int=0;
public function sayHi(event:Event = null):void
{
if(counter++%30==0)
trace("I'm alive - "+this);
}
]]>
</mx:Script>
<mx:Button />
</mx:TitleWindow>
--- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Please explain further. Calling myPopUp.addEventListener will not keep
> the popup in memory. Instead the popup gets a reference to the object
> that will be called when the event is dispatched.
>