Flex 4.6 Mobile Application
I am getting the error “access to undefined property PrepForDisplay”
In my Declarations tag I have
<s:CurrencyFormatter id="PrepForDisplay"
currencySymbol=""
useCurrencySymbol="true"
negativeCurrencyFormat="0"
positiveCurrencyFormat="0"/>
In my MXML section I have
<s:List id="lst" dataProvider="{dp}" useVirtualLayout="true" width="100%" height="95%" top="30" alternatingItemColors="[#66FFFF, #33CCCC]">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:HGroup gap="10">
<s:Label text="{data.Period}" />
**<s:Label text="{PrepForDisplay.format(data.Payment)}" />**
</s:HGroup>
</s:ItemRenderer>
</fx:Component>
The error occurs on the bold line.
If I change it to Number(data.Payment).toFixed(2) everything works fine.
I have used the currencyFormatter the way I have it on other views with success. I can even use it on this view in a function but when I try to apply it in the label I get the error.
Any ideas?
cheers,
My guess is, that its a scoping error, on other words the formatter gets created in the scope of the component, that creates the list, and the itemrenderer gets instantiated be the list. So it does not know of a variable (PrepForDisplay), that is referenced inside the itemrenderer.
To solve it, simply move the CurrencyFormatter tag inside the itemrenderer:
Or simply define the itemrenderer in a separate file.