Perhaps the fix is obvious, but if not just add a couple null checks. After 
all, if "colBGs" is null, then it's certainly not going to be displayed in 
front of "rowBGs" so there's no need to swap them. Something like this should 
do fine:


        override protected function updateDisplayList(unscaledWidth:Number, 
unscaledHeight:Number):void {
            super.updateDisplayList(unscaledWidth, unscaledHeight);
            var rowBGs:DisplayObject = listContent.getChildByName("rowBGs");
            var colBGs:DisplayObject = listContent.getChildByName("colBGs");
            if (rowBGs != null && colBGs != null) {
                var rowBGIndex:int = listContent.getChildIndex(rowBGs);
                var colBGIndex:int = listContent.getChildIndex(colBGs);
                
                if (colBGIndex > rowBGIndex) {
                    listContent.swapChildrenAt(rowBGIndex, colBGIndex);
                }
            }
        }



----- Original Message ----
From: Alex Harui <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Tuesday, July 1, 2008 10:02:59 AM
Subject: RE: [flexcoders] override updateDisplayList


Probably.  If in production the data is
coming off a server and isn’t ready right away, you could be going
through updateDL when there aren’t any rows to draw so the rowBG and
colBG don’t exist yet
 

________________________________
 
From:[EMAIL PROTECTED] ups.com [mailto: [EMAIL PROTECTED] ups.com ] On Behalf 
Of markgoldin_2000
Sent: Tuesday, July 01, 2008 9:11
AM
To: [EMAIL PROTECTED] ups.com
Subject: [flexcoders] override
updateDisplayList
 
I am geting different results if I override
updateDisplayList:
override protected function updateDisplayList( unscaledWidth: Number, 
unscaledHeight: Number):void 
{
super.updateDisplay List(unscaledWid th, unscaledHeight) ;
var rowBGIndex:int = listContent. getChildIndex
(listContent. getChildByName( "rowBGs") );
var colBGIndex:int = listContent. getChildIndex
(listContent. getChildByName( "colBGs") );
}
When I run it from production I am getting this:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display: :DisplayObjectCo ntainer/getChild Index()
at yardmodel.modulecod e::RowColorGrid/ updateDisplayLis t()
at mx.controls. listClasses: :ListBase/ validateDisplayL ist()
at mx.managers: :LayoutManager/ validateDisplayL ist()
at mx.managers: :LayoutManager/ doPhasedInstanti ation()
at Function/http://adobe. com/AS3/2006/ builtin:: apply()
at mx.core::UIComponen t/callLaterDispa tcher2()
at mx.core::UIComponen t/callLaterDispa tcher()

But when I run from Flex Builder it works fine. I am not running 
againt same data, but is that a problem?

Please help.    


      

Reply via email to