I have a datagrid with an location and a list of activities Birdwatching, Boating, Camping. The datagrid is populated based on either a simple yes or no if the activity is offered at that location. I want to replace the yes / no with a separate image for each activity. I created a imagerender and I'm able to get the image to change but only to the birdwatching image. My question is, how can I get it to loop through that datagrid and display image according to the value?
Thanks.
package widgets.Samples.CononGeocoder2
{
import mx.containers.HBox;
import mx.controls.Image;
import mx.controls.Label;
import mx.controls.dataGridClasses.*;
public class ImageRenderer extends HBox
{
private var imageReference:Image = null;
private var imageReference2:Image = null;
private var imageReference3:Image = null;
private var lbl:Label = new Label();
private var img:Image = new Image();
private var img2:Image = new Image();
private var img3:Image = new Image();
override public function set data(value:Object):void
{
//if(value != null && imageReference == null)
{
for each(data in value)
{
if(value.Birdwatching == "yes") {
img.source = "assets/images/Birdwatching.png";
addChild(img)
lbl.text = "(" + value.Birdwatching + ")";
img.toolTip = "Birdwatching";
imageReference = img;
setStyle("verticalAlign", "middle");
setStyle("paddingLeft","5");
}
if(value.Boating == "yes"){
img2.source = "assets/images/Boating.png";
addChild(img2)
lbl.text = "(" + value.Boating + ")";
img2.toolTip = "Boating";
imageReference2 = img2;
setStyle("verticalAlign", "middle");
setStyle("paddingLeft","5");
}
if(value.Camping == "yes"){
img3.source = "assets/images/Camping.png";
addChild(img3)
lbl.text = "(" + value.Camping + ")";
img3.toolTip = "Camping";
imageReference3 = img3;
setStyle("verticalAlign", "middle");
setStyle("paddingLeft","5");
}
//Place
}
}
}
}
}