뷰에 두 개의 스크립트가 있습니다. 한 스크립트는 구성 요소 안에 있습니다. Component 스크립트에서 데이터에 숫자를 추가하려면 목록에 추가 된 다음 View에있는 레이블에 총계를 표시해야합니다. 첫 번째 스크립트에서 변수를 선언하면 Component 스크립트는이를 볼 수 없으며 Component Script에서 선언하면 레이블을 볼 수 없습니다. 보기에있는 모든 사람들이 볼 수 있도록 어떻게 선언합니까?Flash Builder 4.5의 로컬 변수
<s:view
<fx:Script>
<![CDATA[
//if I place it here the next CDATA inside IconItemRender can't see it.
private static var MyTotal:Number=0;
]]>
</fx:Script>
<fx:Declarations>
<s:CurrencyFormatter id="usdFormatter" useCurrencySymbol="true"/>
</fx:Declarations>
<s:itemRenderer>
<fx:Component>
<s:IconItemRender ..............>
<fx:Script>
<![CDATA[
//if I place it here the Label "TotalAmountLb" can't see it.
// and it get reset to 0 everytime I call the function getInvoiceAmount.
private static var MyTotal:Number=0;
private function getInvoiceAmount(item:Object):String
{
MyTotal = MyTotal + Number(item.Amount);
}
]]>
</fx:Script>
</s:IconItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
<s:Label id="TotalAmountLb" text="{usdFormatter.format(MyTotal)}"/>
</s:view>
귀하의 질문에 이해가되지 않습니다. 먼저 질문을 분명히하십시오. – Exhausted
좀 더 명확하게 설명하고 코드를 보여주십시오. – JeffryHouser
이 권리를 이해한다면 구성 요소에 대한 ID를 제공해야합니다. id를 사용하면 구성 요소 내부에서 변수를 참조 할 수 있습니다. 다른 방법은 구성 요소에서 디스패치 사용자 지정 이벤트를 보는 것입니다. –