header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
flex
Points:0
Posts:0

6/13/2010 9:47:31 PM

Title: displaying icons in grid column programmatically


hi, I have dynamically created advanced datagrid..I want to display one icons in column if value is male, or if value is female i want to display another icon.. my code is,

column.itemRenderer=new averageComponent();




public class averageComponent extends Image implements IFactory
{


[Bindable]
[Embed(source='/assets/maleButton.png')]
public var male:Class;
[Bindable]
[Embed(source='assets/femaleButton.png')]
public var female:Class;


public function averageComponent()
{
super();
}
override public function set data(value:Object):void
{
if(value != null)
{
super.data = value;


var img:Image = new Image();



var dField:String = DataGridListData(listData).dataField;

//Alert.show(dField);
if(data[dField] =="M")
{



img.source = new male();
addChild(img);
belowAverage();

}
else
{
img.source = new female();
addChild(img);


}
}
}



public function newInstance():*
{
return new averageComponent();

}
}



but im not able to display the icon in grid column.. i have tried with all possible image paths also..but it is not working.. can anyone suggest me where im doing mistake?




1
sakthi
Points: 0
Posts:0
6/13/2010 11:45:21 PM



img.source = female; try this


2
Matt
Points: 0
Posts:0
6/14/2010 1:24:10 AM



The code should be simple enough. You can simply write a function inside the item renderer which returns the image path. Below is just an code idea , syntax may not be correct as I am writing in notepad only. i.e

function imagePath(val:String):String{
if(val=="M"){
return femaleImage;
}else
{
return femaleImage;
}
}


<mx:image source="{imagePath(data[dField] =="M")}"


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 8+8 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions