我正在尝试以编程方式为 CategoryAxis 提供我自己的 labelFunction,但我完全被难住了。常规方法是在您的 MXML 文件中执行此操作,但我想在我的 Actionscript 文件中执行此操作。
常规的做法是:
<mx:Script>
<![CDATA[
private function categoryAxis_labelFunc(item:Object,
prevValue:Object,
axis:CategoryAxis,
categoryItem:Object):String {
return "Some String";
}
]]>
</mx:Script>
<mx:CategoryAxis labelFunction="categoryAxis_labelFunc" />
但我想在我的 CategoryAxis 子类中实现相同的目标,例如:
public class FauxDateAxis extends CategoryAxis {
public function FauxDateAxis() {
super();
labelFunction = categoryAxis_labelFunc // Doesn't work of course.
}
private function categoryAxis_labelFunc(item:Object,
prevValue:Object,
axis:CategoryAxis,
categoryItem:Object):String {
return "Another String";
}
}