« Return to Thread: item renderer in ComboBox not consistent

Re: Re: item renderer in ComboBox not consistent

by Jeffry Houser :: Rate this Message:

Reply to Author | View in Thread


  Use the dataChange event.  Even if the data changes, the renderer is
not re-created and creationComplete will not run again.

Mic wrote:

> Hi Jeff, what this does is set the background color of the renderer's VBox and therefore the line shading to gray if the label text begins with an asterisk .... we want to highlight these paricular rows in the list. I know what you are saying about creationComplete() only running once, but I was thinking the renderer would have to redo itself on a scroll because the viewable area had changed.
>
> --- In flexcoders@..., Jeffry Houser <jeff@...> wrote:
>  
>>  It looks like you are trying to change the background color of the
>> label so that you have alternating colors, is that correct?
>>  This won't work due to render recycling.  Renderers are re-used.  There
>> is not a single renderer for every item in your dataProvider.  
>> CreationComplete complete only runs once.
>>
>>  You might try code like this on the dataChange event.  Or using
>> updateComplete.
>>
>>  Or google it and discover the alternatingItemColors style:
>> http://blog.flexexamples.com/2007/08/17/alternating-row-colors-in-a-flex-list-control/
>>
>> Mic wrote:
>>    
>>> I thought this might work --- fine until I start scrolling when it gets totally out of wack. The trace does fire occasionally while scrolling but not consistently. Appreciate some hints. TIA,
>>>
>>> Mic.
>>>
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalScrollPolicy="off">
>>> <mx:Script>
>>> <![CDATA[
>>>   private function labelComplete():void{
>>>   trace("Here");
>>>   if(label1.text.substr(0,1) == "*"){
>>>                this.setStyle("backgroundColor", 0xe8e8e3);
>>> }else{
>>>                this.setStyle("backgroundColor", 0xFFFFFF);
>>> }
>>>   }
>>> ]]>
>>> </mx:Script>
>>>         <mx:Label id="label1" text="{data.cmplx_nm}"    creationComplete="labelComplete()"  />
>>> </mx:VBox>
>>>
>>>
>>>
>>> ------------------------------------
>>>
>>> --
>>> Flexcoders Mailing List
>>> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>>> Alternative FAQ location: https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
>>> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
>>>
>>>
>>>
>>>
>>>  
>>>      
>> --
>> Jeffry Houser, Technical Entrepreneur
>> Adobe Community Expert: http://tinyurl.com/684b5h
>> http://www.twitter.com/reboog711  | Phone: 203-379-0773
>> --
>> Easy to use Interface Components for Flex Developers
>> http://www.flextras.com?c=104
>> --
>> http://www.theflexshow.com
>> http://www.jeffryhouser.com
>> --
>> Part of the DotComIt Brain Trust
>>
>>    
>
>
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location: https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
>
>
>
>
>  

--
Jeffry Houser, Technical Entrepreneur
Adobe Community Expert: http://tinyurl.com/684b5h
http://www.twitter.com/reboog711  | Phone: 203-379-0773
--
Easy to use Interface Components for Flex Developers
http://www.flextras.com?c=104
--
http://www.theflexshow.com
http://www.jeffryhouser.com
--
Part of the DotComIt Brain Trust

 « Return to Thread: item renderer in ComboBox not consistent