I think your problem is related to your bindings. BindingUtils.bindProperty
is being given an your panel
instance, trying it to the object graph and making it inapplicable for garbage collection.
bindProperty
returns a ChangeWatcher
, which you can use to unregister the binding when you are done with it. Something like the following:
var watchers : Array = [];
var panel:SuperPanel = new SuperPanel();
panel.width = 300;
panel.height = 200;
panel.minWidth = 200;
panel.minHeight = 100;
panel.title = "My Panel " + (panelContainer.numChildren + 1);
panel.addEventListener(CloseEvent.CLOSE, function(event:CloseEvent):void{
for each(var watcher : ChangeWatcher in watchers) {
watcher.unwatch();
}
event.target.parent.removeChild(event.target);
});
watchers.push(BindingUtils.bindProperty(panel, "allowDrag", allowDragCheck, "selected"));
watchers.push(BindingUtils.bindProperty(panel, "allowResize", allowResizeCheck, "selected"));
watchers.push(BindingUtils.bindProperty(panel, "allowClose", allowCloseCheck, "selected"));
watchers.push(BindingUtils.bindProperty(panel, "allowMaximize", allowMaxCheck, "selected"));
watchers.push(BindingUtils.bindProperty(panel, "allowMinimize", allowMinCheck, "selected"));
panelContainer.addChild(panel);
Also, you have not overridden the clone
event in SuperPanelEvent
which will cause you issues later. See this question for more details.