PDA

View Full Version : Dynamically change color in XML datagrid


Jakbaehl
11-06-2006, 10:25 AM
Hi professionals.

I have a flash datagrid, that is XML driven, and uses a XML connector and a dataset.
This grid is displaying a price list.

I have been caught in a deadlock regarding how to dynamically set the color for sold objects red.

I have this object: <STATUS></STATUS>

This being sold or available. I would like the status column to check the status tag to see if it is sold or not, and then set the colors green or red respectively.

I have pondered this one for quite some time without figuring out how. Please help!?!?!

myFUD
12-01-2006, 02:59 PM
Set a stylesheet for the node according to when the value hits certain logic.


var my_style:TextField.StyleSheet = new TextField.StyleSheet();
var itemSold:Boolean=statusNode.value;

if (itemSold){
my_style.setStyle ("status", {
color:'#009933'
})
} else {
my_style.setStyle ("status", {
color:'#cc0000'
})
}
status_txt.styleSheet = my_style;
status_txt.text=statusNode

I haven't tested this, but logically it should work. You may have to play around with it a little.