To add to Ravis post, you can invalidateProperties() on set data() and
do the icon assignment in commitProperites()
Its worth the effort if you have a huge list to be displayed and a
best practice building renderers or for that matter any other custom
components.
override public function set data(value:Object):void{
super.data = value;
_myData = value; // private var
dataChanged = true; // flag
}
override protected function commitProperties():void
{
super.commitProperties();
if( dataChanged )
{
dataChanged = false;
if(_myData .Gender == "Male"){
//male icon
}
else{
//female Icon
}
}
}
On Apr 17, 2:59 pm, sankar swaroop <[email protected]> wrote:
> Thanks Ravi.
> you helped alot
> Thank u very much
>
> On Fri, Apr 17, 2009 at 10:52 AM, Ravi Mishra <[email protected]>wrote:
>
>
>
>
>
> > Hi Sankar,
>
> > Dont override the UpdateDisplayList method here. For itemrenderer you
> > need to overried the set data method and then write your logic there
>
> > override public function set data(value:Object):void{
> > super.data = value;
> > if(value.Gender == "Male"){
> > //male icon
> > }
> > else{
> > //female Icon
> > }
> > }
>
> > HTH,
>
> > -Ravi
>
> > On Apr 16, 7:33 pm, sankar swaroop <[email protected]> wrote:
> > > Hi friends,
>
> > > i am displaying gender in grid as Male and Female.
> > > But now i want to display male and female as icons like
> > > based on the condition if male it needs to display one icon
> > > and if female another icon should be displayed.
>
> > > I created itemrenderer to that like below:
>
> > > *
>
> > > package*{
>
> > > **
>
> > > *import* mx.controls.Image;
>
> > > *public* *class* GenderIcons *extends* Image
>
> > > {
>
> > > **
>
> > > [*Bindable*]
>
> > > [*Embed*(source=*'icons/male.png'*)]
>
> > > *public* *var* male:Class;
>
> > > [*Bindable*]
>
> > > [*Embed*(source=*'icons/female.png'*)]
>
> > > *public* *var* female:Class;
>
> > > *override* *protected* *function* updateDisplayList(unscaledWidth:Number,
> > > unscaledHeight:Number):*void
> > > *
>
> > > {
>
> > > *super*.updateDisplayList(unscaledWidth,unscaledHeight);
>
> > > setStyle(*"icon"*,(da...@gender == *"Male"*)?male:female);
>
> > > }
> > > }
> > > }
>
> > > But it is not displaying anything. Is there any error in code
>
> > > Please help me
>
> > > Thanks in advance
>
> > > Bye....- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---