I've been working with the flex charting component and I want to embed a custom icon for the marker in the legend. I've run into some strange behaviour where if set directly the icon is mirrored and the text is misaligned but if created using the a class factory and the legendMarkerRenderer property the component renders fine. I've included a snippet to illustrate the problem below.
Working around this problem may be possible but I'm curious if anyone has an explanation as to what could be going on here.
Additional info: Flex SDK 4.5.0.20967, FlashBuilder 4.5
This is the output of the below snippet:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
import mx.charts.LegendItem;
[Embed(source="/resources/GraphResetIcon.png")]
public static var icon:Class;
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<!-- This works fine -->
<mx:LegendItem legendMarkerRenderer="{new ClassFactory(icon)}" markerAspectRatio="1"
labelPlacement="right" label="Texty texty" markerHeight="11" markerWidth="11" />
<!-- This does not work -->
<mx:LegendItem marker="{new icon()}" markerAspectRatio="1" labelPlacement="right"
label="Texty texty" markerHeight="11" markerWidth="11" />
</s:Application>
Try
Edit:
I dug out my backup hard drive, and here is what works for me
In principle, this is almost the same as what you started out with, but I explicitly cast the newly created Class instance to BitmapAsset.