Hey guys...

I'm working on an application where I'm constantly creating and
removing panels. I've read the creation of components is really
expensive, so I'm trying to recycle the panels the user closes. In
order to do that I'm using a "cache" array. When the user closes the
panel, I remove all the children of the panel and store it in the
cache like this:

                private function panelClosedHandler (event:FlexEvent):void
                {
                        var panel:Panel = event.currentTarget as Panel;
                        if ( ! viewsCache )
                        {
                                cache = [];
                        }

                        cache.push( panel );

                }


When the user asks for a new panel to be instantiated I check if the
cache have any views... If it does I get one of the panels stored. If
it doesn't I create a new Panel instance. This is the function:



                private function createPanel( ):void
                {
                        var module:ModuleLoader;
                        var panel:Panel;
                        
                        if ( cache && cache.length > 0 )
                        {
                                panel = viewsCache.pop() as Panel;
                                module = new ModuleLoader () // im trying to 
reuse this as well.
                        }
                        else
                        {
                                panel = new Panel();
                                module = new ModuleLoader ();
                        }
                        
             // and adds to the module container.           
           
pnl_panelsContainer.addChildAt(panel,this.pnl_panelsContainer.getChildren().length);

              }


The problem is, when I get an instance of a recycled panel from the
cache the component doesn't get drawed in the screen. The x, y, width
and heigth properties are assigned but the panel appear as a white
rectangle. Its borders are not drawed, and have no titleBar. 

Can anyone help me with this?

Thanx a lot guys,
DaNooB





Reply via email to