1

我正在做一个项目,我连续有 5 张图片。这些图像需要根据 if、if else、else 语句的结果进行更改(红色、黄色、绿色)。我有一些 javascript 可以做到这一点,但我需要在 ActionScript3 中使用它以与 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";
}

谢谢,我是 JavaScript 和 Flex 的新手。

4

1 回答 1

2

如果您不知道如何将图像加载到 Flash/Flex 中,这将是一个很好的起点image组件是将图像放入 Flex 应用程序的常用方法,嵌入将允许更改更快地发生,尽管只有少量图像并不重要。嵌入后,您可以设置source属性:

[Embed(source="green_led.png")]
[Bindable]
public var greenLed:Class;
// ...etc

if ((billableMonthHours/targetMTD) >= 1)
{
MTDstatus.source = greenLed;
}
else if (billableMonthHours/targetMTD) >= 0.95)
// ...etc
于 2012-05-31T23:20:35.210 回答