我正在开展一个项目,我连续有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的新手。
答案 0 :(得分:2)
如果您不知道如何将图像加载到Flash / Flex中,this would be a good place to start。 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