I’m working on a project and I have 5 images in a row. These images need to change (red, yellow, green) based on the outcome of an if, if else, else statement.
I have some javascript that will do it but I need it in ActionScript3 for use with Flex 4.6.
JavaScript– VV
if ((billableMonthHours/targetMTD) >= 1)
{
MTDstatus.src = "green_led.png";
}
else if (((billableMonthHours/targetMTD) < 1) && ((billableMonthHours/targetMTD) >= 0.95))
{
MTDstatus.src = "yellow_led.png";
}
else //if ((billableMonthHours/targetMTD) < 0.95)
{
MTDstatus.src = "red_led.png";
}
if ((billableQuarterHours/targetQTD) >= 1)
{
QTDstatus.src = "green_led.png";
}
else if (((billableQuarterHours/targetQTD) < 1) && ((billableQuarterHours/targetQTD) >= 0.95))
{
QTDstatus.src = "yellow_led.png";
}
else //if ((billableQuarterHours/targetQTD) < 0.95)
{
QTDstatus.src = "red_led.png";
}
if ((totalRecordedHours-mtdWorkingHours) >= 0)
{
UTDcards.src = "green_led.png";
}
else if (((totalRecordedHours-mtdWorkingHours) >= -4) && ((totalRecordedHours-mtdWorkingHours) < 0))
{
UTDcards.src = "yellow_led.png";
}
else //if ((totalRecordedHours-mtdWorkingHours) < -4)
{
UTDcards.src = "red_led.png";
}
Thanks, I’m new to both JavaScript and Flex.
If you don’t know how to load the images into Flash/Flex, this would be a good place to start. The
imagecomponent is the usual way to put an image into a Flex application, and embedding will allow changes to happen faster, though with only a few images it shouldn’t matter. Once it’s embedded, you can set thesourceproperty: