Re: [flexcoders] Re: Spark DropDownList Custom ItemRenderer Issue

2010-04-08 Thread Alex Harui
That is discussed here (under recycling): http://blogs.adobe.com/aharui/2007/03/


On 4/8/10 4:22 PM, jmfillman jmfill...@verizon.net wrote:






I was wondering if you could post an example of what is meant by derive the 
visuals. I can see the same thing happening in my renderer, but I'm not sure 
what to do to correct it.

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , 
azona26 azsl1326-em...@... wrote:

 Got it! Thanks for the additional insight as that is exactly what I needed to 
 do.

 --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , 
 Alex Harui aharui@ wrote:
 
  You must derive all visuals, and that means resetting the color if it 
  doesn't meet the criteria.
 
 
  On 3/29/10 10:44 AM, azona26 azsl1326-email@ wrote:
 
 
 
 
 
 
  Thanks. However switching to dataChange event causes all items in the 
  DropDownList to change their text color.
 
  --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com  
  mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote:
  
   The rules for itemrenderers haven't changed that much.  You must still 
   derive all of your visuals from the data property.  Use dataChange 
   instead of creationComplete.
  
  
   On 3/29/10 9:32 AM, azona26 azsl1326-email@ wrote:
  
  
  
  
  
  
   Here's the code:
  
   s:ItemRenderer xmlns:fx=http://ns.adobe.com/mxml/2009;
   xmlns:s=library://ns.adobe.com/flex/spark
   xmlns:mx=library://ns.adobe.com/flex/mx
   autoDrawBackground=true height=20
   creationComplete=itemrenderer_creationCom! pleteHandler(event)
   fx:Script
   ![CDATA[
   import com.usa.model.ThumbnailModel;
   import com.usa.model.presentation.LightBoxPresenationModel;
   import mx.events.FlexEvent;
   import mx.utils.StringUtil;
   [Inject][Bindable]
   public var lightBoxPM:LightBoxPresenationModel;
   [Inject][Bindable]
   ! public var tnModel:ThumbnailModel;
   protected var lightBoxNames_arr:Array
   protected function 
   itemrenderer_creationCompleteHandler(event:FlexEvent):void {
   var lbl:String = StringUtil.trimArrayElements(tnModel.d! 
   ata.asset_lightboxes,,)
   lightBoxNames_arr = lbl.split(,);
   lightBoxNames_arr.reverse();
   var len:int = lightBoxNames_arr.length
   for (var i:int = 0; i  len; i++) {
   // i.e. 'Lightbox #1' == 'Lightbox #1'
   if( lblDisplay.text == lightBoxNames_arr[i]){
   lblDisplay.setStyle('color','#BB');
   this.autoDrawBackground = false;
   }
   }
   }
  
   ]]
   /fx:Script
   s:Label toolTip={data.name}
id=lblDisplay
top=6 left=2 right=2 bottom=2
text={data.name} /
   /s:ItemRenderer
  
   Thanks for the assistance!
  
   --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com  
   mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote:
   
What does your renderer code look like?
   
   
On 3/29/10 8:08 AM, azona26 azsl1326-email@ wrote:
   
   
   
   
   
   
I have a Spark DropDownList that has a custom ItemRenderer. The 
ItemRenderer, upon creation, checks th! e label text and if it matches 
certain criteria, then the labe! l text c olor changes. The label text 
color is changing, however it is for the wrong label. What appears to 
be happening is that the label color that is actually being changed is 
in reverse order of how the labels are displayed in the drop down list.
   
For example, the list contains the text labels: One, Two, Three, Four, 
and is being displayed in that exact order. I am checking for the label 
One and then changing it's text color. What actually ends up ! 
happening is that the text color for Four (first item from bottom) is 
actually being changed. If I check for the text label, Three, then 
the text color for Two (third item from bottom) gets changed. If I 
check for the label text Four, the text color for One (fourth item 
from bottom) gets changes. This functionality seems to hold true for 
each item in the DropDownList.
   
Any suggestions on how to resolve this issue so that the correct text 
color is being changed?
   
Thanks for th! e assistance.
   
   
   
   
   
--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui
   
  
  
  
  
  
   --
   Alex Harui
   Flex SDK Team
   Adobe System, Inc.
   http://blogs.adobe.com/aharui
  
 
 
 
 
 
 
  --
  Alex Harui
  Flex SDK Team
  Adobe System, Inc.
  http://blogs.adobe.com/aharui
 







--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui


Re: [flexcoders] Re: Spark DropDownList Custom ItemRenderer Issue

2010-04-08 Thread Alex Harui
Let’s get rid of creationComplete and wire up to dataChange or override the 
data setter and see what happens.


On 4/8/10 5:23 PM, jmfillman jmfill...@verizon.net wrote:






I understand that itemRenderers are reused, however, my renderer always set's 
the label and the color, so it would seem to me that this would always 
overwrite what was set previously. What's causing me issue is that the items in 
the DropDownList display in the reverse order of the dataProvider, but when I 
select an item in the DropDownList, the selectedIndex and selectedItem are 
referencing the order from the dataProvider, and not what is displayed in the 
DropDownList.

DropDownList:

s:DropDownList id=itemType dataProvider={categories} 
itemRenderer=skins.itemTypeRenderer labelField=name includeIn=edit, new 
top=95 height=30 left=86 selectedIndex.new=0 
sellectedIndex.edit={hostComponent.colorIndex} 
change={hostComponent.colorIndex=itemType.selectedIndex}; 
{hostComponent.color=itemType.selectedItem.value} /

ItemRenderer:
?xml version=1.0 encoding=utf-8?
s:ItemRenderer xmlns:fx=http://ns.adobe.com/mxml/2009;
xmlns:s=library://ns.adobe.com/flex/spark
xmlns:mx=library://ns.adobe.com/flex/mx
autoDrawBackground=true creationComplete=init();

fx:Script
![CDATA[
import mx.utils.ObjectProxy;

[Bindable] public var dataProxy:ObjectProxy;

private function init():void {
dataProxy = new ObjectProxy(data);
}
]]
/fx:Script

s:HGroup top=0 bottom=0 left=0 right=0
s:Rect id=catColor height=10 width=10 radiusX=20
s:fill
!--- @private --
s:SolidColor id=catFill color={dataProxy.value}/
/s:fill
/s:Rect
s:Label id=labelDisplay text={dataProxy.name}/
/s:HGroup
/s:ItemRenderer

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex 
Harui aha...@... wrote:

 That is discussed here (under recycling): 
 http://blogs.adobe.com/aharui/2007/03/


 On 4/8/10 4:22 PM, jmfillman jmfill...@... wrote:






 I was wondering if you could post an example of what is meant by derive the 
 visuals. I can see the same thing happening in my renderer, but I'm not sure 
 what to do to correct it.

 --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com  
 mailto:flexcoders%40yahoogroups.com , azona26 azsl1326-email@ wrote:
 
  Got it! Thanks for the additional insight as that is exactly what I needed 
  to do.
 
  --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com  
  mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote:
  
   You must derive all visuals, and that means resetting the color if it 
   doesn't meet the criteria.
  
  
   On 3/29/10 10:44 AM, azona26 azsl1326-email@ wrote:
  
  
  
  
  
  
   Thanks. However switching to dataChange event causes all items in the 
   DropDownList to change their text color.
  
   --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com  
   mailto:flexcoders%40yahoogroups.com  
   mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote:
   
The rules for itemrenderers haven't changed that much.  You must still 
derive all of your visuals from the data property.  Use dataChange 
instead of creationComplete.
   
   
On 3/29/10 9:32 AM, azona26 azsl1326-email@ wrote:
   
   
   
   
   
   
Here's the code:
   
s:ItemRenderer xmlns:fx=http://ns.adobe.com/mxml/2009;
xmlns:s=library://ns.adobe.com/flex/spark
xmlns:mx=library://ns.adobe.com/flex/mx
autoDrawBackground=true height=20
creationComplete=itemrenderer_creationCom! pleteHandler(event)
fx:Script
![CDATA[
import com.usa.model.ThumbnailModel;
import com.usa.model.presentation.LightBoxPresenationModel;
import mx.events.FlexEvent;
import mx.utils.StringUtil;
[Inject][Bindable]
public var lightBoxPM:LightBoxPresenationModel;
[Inject][Bindable]
! public var tnModel:ThumbnailModel;
protected var lightBoxNames_arr:Array
protected function 
itemrenderer_creationCompleteHandler(event:FlexEvent):void {
var lbl:String = StringUtil.trimArrayElements(tnModel.d! 
ata.asset_lightboxes,,)
lightBoxNames_arr = lbl.split(,);
lightBoxNames_arr.reverse();
var len:int = lightBoxNames_arr.length
for (var i:int = 0; i  len; i++) {
// i.e. 'Lightbox #1' == 'Lightbox #1'
if( lblDisplay.text == lightBoxNames_arr[i]){
lblDisplay.setStyle('color','#BB');
this.autoDrawBackground = false;
}
}
}
   
]]
/fx:Script
s:Label toolTip={data.name}
 id=lblDisplay
 top=6 left=2 right=2 bottom=2
 text={data.name} /
/s:ItemRenderer
   
Thanks for the assistance!
   
--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
 mailto:flexcoders%40yahoogroups.com  
mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote:

 What does your renderer code look like?


 On 3/29/10 8:08 AM, azona26 azsl1326-email@ wrote:






 I have a Spark DropDownList that has a custom 

Re: [flexcoders] Re: Spark DropDownList Custom ItemRenderer Issue

2010-03-29 Thread Alex Harui
The rules for itemrenderers haven’t changed that much.  You must still derive 
all of your visuals from the data property.  Use dataChange instead of 
creationComplete.


On 3/29/10 9:32 AM, azona26 azsl1326-em...@yahoo.com wrote:






Here's the code:

s:ItemRenderer xmlns:fx=http://ns.adobe.com/mxml/2009;
xmlns:s=library://ns.adobe.com/flex/spark
xmlns:mx=library://ns.adobe.com/flex/mx
autoDrawBackground=true height=20
creationComplete=itemrenderer_creationCom! pleteHandler(event)
fx:Script
![CDATA[
import com.usa.model.ThumbnailModel;
import com.usa.model.presentation.LightBoxPresenationModel;
import mx.events.FlexEvent;
import mx.utils.StringUtil;
[Inject][Bindable]
public var lightBoxPM:LightBoxPresenationModel;
[Inject][Bindable]
! public var tnModel:ThumbnailModel;
protected var lightBoxNames_arr:Array
protected function itemrenderer_creationCompleteHandler(event:FlexEvent):void {
var lbl:String = StringUtil.trimArrayElements(tnModel.d! 
ata.asset_lightboxes,,)
lightBoxNames_arr = lbl.split(,);
lightBoxNames_arr.reverse();
var len:int = lightBoxNames_arr.length
for (var i:int = 0; i  len; i++) {
// i.e. 'Lightbox #1' == 'Lightbox #1'
if( lblDisplay.text == lightBoxNames_arr[i]){
lblDisplay.setStyle('color','#BB');
this.autoDrawBackground = false;
}
}
}

]]
/fx:Script
s:Label toolTip={data.name}
 id=lblDisplay
 top=6 left=2 right=2 bottom=2
 text={data.name} /
/s:ItemRenderer

Thanks for the assistance!

--- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote:

 What does your renderer code look like?


 On 3/29/10 8:08 AM, azona26 azsl1326-em...@... wrote:






 I have a Spark DropDownList that has a custom ItemRenderer. The ItemRenderer, 
 upon creation, checks th! e label text and if it matches certain criteria, 
 then the labe! l text c olor changes. The label text color is changing, 
 however it is for the wrong label. What appears to be happening is that the 
 label color that is actually being changed is in reverse order of how the 
 labels are displayed in the drop down list.

 For example, the list contains the text labels: One, Two, Three, Four, and is 
 being displayed in that exact order. I am checking for the label One and 
 then changing it's text color. What actually ends up ! happening is that the 
 text color for Four (first item from bottom) is actually being changed. If 
 I check for the text label, Three, then the text color for Two (third 
 item from bottom) gets changed. If I check for the label text Four, the 
 text color for One (fourth item from bottom) gets changes. This 
 functionality seems to hold true for each item in the DropDownList.

 Any suggestions on how to resolve this issue so that the correct text color 
 is being changed?

 Thanks for th! e assistance.





 --
 Alex Harui
 Flex SDK Team
 Adobe System, Inc.
 http://blogs.adobe.com/aharui






--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui


Re: [flexcoders] Re: Spark DropDownList Custom ItemRenderer Issue

2010-03-29 Thread Alex Harui
You must derive all visuals, and that means resetting the color if it doesn’t 
meet the criteria.


On 3/29/10 10:44 AM, azona26 azsl1326-em...@yahoo.com wrote:






Thanks. However switching to dataChange event causes all items in the 
DropDownList to change their text color.

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex 
Harui aha...@... wrote:

 The rules for itemrenderers haven't changed that much.  You must still derive 
 all of your visuals from the data property.  Use dataChange instead of 
 creationComplete.


 On 3/29/10 9:32 AM, azona26 azsl1326-em...@... wrote:






 Here's the code:

 s:ItemRenderer xmlns:fx=http://ns.adobe.com/mxml/2009;
 xmlns:s=library://ns.adobe.com/flex/spark
 xmlns:mx=library://ns.adobe.com/flex/mx
 autoDrawBackground=true height=20
 creationComplete=itemrenderer_creationCom! pleteHandler(event)
 fx:Script
 ![CDATA[
 import com.usa.model.ThumbnailModel;
 import com.usa.model.presentation.LightBoxPresenationModel;
 import mx.events.FlexEvent;
 import mx.utils.StringUtil;
 [Inject][Bindable]
 public var lightBoxPM:LightBoxPresenationModel;
 [Inject][Bindable]
 ! public var tnModel:ThumbnailModel;
 protected var lightBoxNames_arr:Array
 protected function itemrenderer_creationCompleteHandler(event:FlexEvent):void 
 {
 var lbl:String = StringUtil.trimArrayElements(tnModel.d! 
 ata.asset_lightboxes,,)
 lightBoxNames_arr = lbl.split(,);
 lightBoxNames_arr.reverse();
 var len:int = lightBoxNames_arr.length
 for (var i:int = 0; i  len; i++) {
 // i.e. 'Lightbox #1' == 'Lightbox #1'
 if( lblDisplay.text == lightBoxNames_arr[i]){
 lblDisplay.setStyle('color','#BB');
 this.autoDrawBackground = false;
 }
 }
 }

 ]]
 /fx:Script
 s:Label toolTip={data.name}
  id=lblDisplay
  top=6 left=2 right=2 bottom=2
  text={data.name} /
 /s:ItemRenderer

 Thanks for the assistance!

 --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , 
 Alex Harui aharui@ wrote:
 
  What does your renderer code look like?
 
 
  On 3/29/10 8:08 AM, azona26 azsl1326-email@ wrote:
 
 
 
 
 
 
  I have a Spark DropDownList that has a custom ItemRenderer. The 
  ItemRenderer, upon creation, checks th! e label text and if it matches 
  certain criteria, then the labe! l text c olor changes. The label text 
  color is changing, however it is for the wrong label. What appears to be 
  happening is that the label color that is actually being changed is in 
  reverse order of how the labels are displayed in the drop down list.
 
  For example, the list contains the text labels: One, Two, Three, Four, and 
  is being displayed in that exact order. I am checking for the label One 
  and then changing it's text color. What actually ends up ! happening is 
  that the text color for Four (first item from bottom) is actually being 
  changed. If I check for the text label, Three, then the text color for 
  Two (third item from bottom) gets changed. If I check for the label text 
  Four, the text color for One (fourth item from bottom) gets changes. 
  This functionality seems to hold true for each item in the DropDownList.
 
  Any suggestions on how to resolve this issue so that the correct text color 
  is being changed?
 
  Thanks for th! e assistance.
 
 
 
 
 
  --
  Alex Harui
  Flex SDK Team
  Adobe System, Inc.
  http://blogs.adobe.com/aharui
 





 --
 Alex Harui
 Flex SDK Team
 Adobe System, Inc.
 http://blogs.adobe.com/aharui







--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui