문제

첫 번째 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"/>

도움이 되었습니까?

해결책

In a vacuum, that code runs fine on my laptop (if I add in a CC control).

I rewrote it a bit to fast exit and that might improve things a bit in some cases.

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

다른 팁

build one component for what you want to do and import that component into main application and use. then file size will decrease and performance will increase.

It strange that it runs slowly. Nothing special happens in the code.

Yes, the code is not clean, but that doesn't influence performance here.

Try to run Flex Profiler and find possible bottlenecks, if they exist.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top