2009-11-27 2 views
0

첫 번째 Adobe Flex 응용 프로그램을 작성 중이며 매우 느리게 실행되는 코드 섹션이 있지만 제대로 작동합니다!이 Adobe Flex 스크립트의 속도를 어떻게 향상시킬 수 있습니까?

CC_Output는 어떤 도움을 크게 감상 할 수

텍스트 컨트롤, 다른 모든 컨트롤이 체크 박스입니다 (CC, CC_Duration 등)입니다!

<mx:Script>     


     private function updateLabel():void { 
      var HPI_Score:Number = 0; 
      if (CC.selected) {CC_Output.text = "CC/HPI - Brief";} 

      if (!CC.selected) { 
       CC_Output.text = "CC/HPI - Inadequate"; 
      } else { 

       if (CC_Duration.selected) {HPI_Score=HPI_Score+1;} 
       if (CC_Location.selected) {HPI_Score=HPI_Score+1;} 
       if (CC_Quality.selected) {HPI_Score=HPI_Score+1;} 
       if (CC_Severity.selected) {HPI_Score=HPI_Score+1;} 
       if (CC_Timing.selected) {HPI_Score=HPI_Score+1;} 
       if (CC_Context.selected) {HPI_Score=HPI_Score+1;} 
       if (CC_Modify.selected) {HPI_Score=HPI_Score+1;} 
       if (CC_Assoc.selected) {HPI_Score=HPI_Score+1;} 
       if (CC_Chronic_Dx.selected) {HPI_Score=HPI_Score+4;} 

       if (HPI_Score > 3) {CC_Output.text = "CC/HPI - Extended";} 
      } 
     } 

</mx:Script> 
<mx:TextArea id="LBL" x="262" y="28" enabled="true" visible="true" width="142"/> 
<mx:CheckBox x="10" y="71" label="Duration" id="CC_Duration" enabled="true" visible="true" click="updateLabel();"/> 
<mx:CheckBox x="10" y="92" label="Location" id="CC_Location" enabled="true" visible="true" click="updateLabel();"/> 
<mx:CheckBox x="10" y="113" label="Quality" id="CC_Quality" enabled="true" visible="true" click="updateLabel();"/> 
<mx:CheckBox x="10" y="134" label="Severity" id="CC_Severity" enabled="true" visible="true" click="updateLabel();"/> 
<mx:CheckBox x="10" y="155" label="Timing" id="CC_Timing" enabled="true" visible="true" click="updateLabel();"/> 
<mx:CheckBox x="10" y="176" label="Context" id="CC_Context" enabled="true" visible="true" click="updateLabel();"/> 
<mx:CheckBox x="10" y="197" label="Modifying Factors" id="CC_Modify" enabled="true" visible="true" click="updateLabel();"/> 
<mx:CheckBox x="10" y="218" label="Assoc Signs/Symptoms" id="CC_Assoc" enabled="true" visible="true" click="updateLabel();"/> 
<mx:CheckBox x="10" y="239" label="Status of 3 Chronic Dx" id="CC_Chronic_Dx" enabled="true" visible="true" click="updateLabel();"/> 
<mx:Label x="10" y="29" text="CC/HPI" fontWeight="bold" id="CC_Output"/> 

+0

나를 위해 빨리 실행됩니다. – Amarghosh

답변

1

진공 상태에서 코드가 내 랩톱에서 제대로 실행됩니다 (CC 컨트롤에 추가 한 경우).

빠른 종료로 약간의 내용을 다시 작성했는데 일부 상황이 개선 될 수 있습니다.

 private function updateLabel():void 
    { 
     const messageInadequate:String = "CC/HPI - Inadequate"; 
     const messageBrief:String = "CC/HPI - Brief"; 
     const messageExtended:String = "CC/HPI - Extended"; 

     if (!CC.selected) 
     { 
      CC_Output.text = messageInadequate; 
      return; 
     } 

     if (CC_Chronic_Dx.selected) 
     { 
      CC_Output.text = messageExtended; 
      return; 
     } 

     var HPI_Score:int = 0; 

     if (CC_Duration.selected) HPI_Score++; 
     if (CC_Location.selected) HPI_Score++; 
     if (CC_Quality.selected) HPI_Score++; 
     if (CC_Severity.selected) HPI_Score++; 
     if (CC_Timing.selected) HPI_Score++; 
     if (CC_Context.selected) HPI_Score++; 
     if (CC_Modify.selected) HPI_Score++; 
     if (CC_Assoc.selected) HPI_Score++; 

     if (4 > HPI_Score) 
     { 
      CC_Output.text = messageBrief; 
     } 
     else 
     { 
      CC_Output.text = messageExtended; 
     } 
    } 
0

빌드는 기본 응용 프로그램 사용에 해당 구성 요소를하고 가져올 것을 위해 하나 개의 구성 요소. 파일 크기가 줄어들고 성능이 향상됩니다.

0

천천히 실행되는 것이 이상합니다. 특별한 것은 없습니다.

예, 코드가 깨끗한 것은 아니지만 여기서는 성능에 영향을주지 않습니다.

Flex 프로필러를 실행하고 가능한 병목 현상 (있는 경우)을 찾으십시오.

관련 문제