2012-05-31 2 views
1

저는 프로젝트에서 작업 중이며 연속으로 5 개의 이미지가 있습니다. 이러한 이미지는 if, if else, else 문의 결과에 따라 변경해야합니다 (빨간색, 노란색, 녹색). 나는 그것을 할 몇 가지 자바 스크립트가 있지만 Flex 4.6에서 사용하기 위해 ActionScript3에서 필요합니다. JavaScript-- VVFlex 4.6의 if 문을 기반으로 이미지를 스왑합니다.

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"; 
} 

덕분에, 나는 자바 스크립트와 플렉스 모두 새로운 해요.

답변

2

플래시/플렉스에 이미지를로드하는 방법을 모르면 this would be a good place to start. image 구성 요소는 이미지를 Flex 응용 프로그램에 삽입하는 일반적인 방법이며, 포함 시키면 변경 사항을 더 빨리 처리 할 수 ​​있지만 몇 개의 이미지 만 있으면 문제가 발생하지 않습니다. `[삽입 (소스 = "green_led.png")] [바인딩] 공공 var에 greenLed : 클래스 [삽입이 내 코드는

[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 
+0

입니다 :이 내장 일단, 당신은 source 속성을 설정할 수 있습니다 (소스 = "red_led.png")] [바인딩] 공개 VAR은 redLed : 등급 [삽입 (소스 = "yellow_led.png")] [바인딩] 공개 VAR은 yellowLed : 등급 를 공용 기능 lightsChange : 무효 { \t var imgObj : BitmapAsset = new greenLed() as BitmapAsset; \t \t 경우 (ratioGA <= 12.5) \t \t \t { GA.source = greenLed; \t한다} else \t 경우 ((ratioGA> 12.5) && ratioGA <= 18.75)) { \t \t \t GA.source = yellowLed; \t한다} else \t 경우 (ratioGA> 20,625) \t \t \t { GA.source = redLed; \t} }'그것을 위해 – paynekidd

+0

내 MXML : ' \t '내가 잘못 뭐하는 거지 ? – paynekidd

+0

lightsChange의 정의에서 누락 된'()'을 제외하고 내가 틀리게 말할 수있는 것은 없습니다. 현재 더 이상 잘못된 코드 나 코드를 제공해야합니다. – CheeseWarlock

관련 문제