代码:
1 应用程序:
- <?xml?version="1.0"?encoding="utf-8"?>?
-
?<s:Application?xmlns:fx="http://ns.adobe.com/mxml/2009"?
-
????????????????xmlns:s="library://ns.adobe.com/flex/spark"?
-
????????????????xmlns:mx="library://ns.adobe.com/flex/halo"?
-
????????????????initialize="init();">?
- ?? ?
-
?????<fx:Script>?
-
?????????<![CDATA[ ?
- ?????????????private?function?init():void?{ ?
- ?????????????????var?fontArr:Array?=?Font.enumerateFonts(true);?/*?device?fonts?only?*/ ?
- ?????????????????arrList?=?new?ArrayList(fontArr.sortOn("fontName")); ?
- ?????????????} ?
- ?????????]]>?
-
?????</fx:Script>?
- ?? ?
-
?????<fx:Declarations>?
-
?????????<s:ArrayList?id="arrList"?/>?
-
?????</fx:Declarations>?
- ?? ?
-
?????<s:List?id="fontList"?
-
?????????????dataProvider="{arrList}"?
-
?????????????labelField="fontName"?
-
?????????????itemRenderer="skins.CustomFontItemRenderer"?
-
?????????????fontSize="24"?
-
?????????????useVirtualLayout="true"?
-
?????????????width="200"?height="200"?
-
?????????????horizontalCenter="0"?verticalCenter="0"?/>?
- ?? ?
-
?</s:Application>?
2 呈视器:
- <?xml?version="1.0"?encoding="utf-8"?>?
-
?<s:ItemRenderer?name="CustomFontItemRenderer"?
-
?????????xmlns:fx="http://ns.adobe.com/mxml/2009"?
-
?????????xmlns:s="library://ns.adobe.com/flex/spark"?
-
?????????focusEnabled="false">?
-
??????
-
?????<s:states>?
-
?????????<s:State?name="normal"?/>?
-
?????????<s:State?name="hovered"?/>?
-
?????????<s:State?name="selected"?/>?
-
?????????<s:State?name="normalAndShowsCaret"?/>?
-
?????????<s:State?name="hoveredAndShowsCaret"?/>?
-
?????????<s:State?name="selectedAndShowsCaret"?/>?
-
?????</s:states>?
- ?? ?
-
?????<fx:Script>?
-
?????????<![CDATA[ ?
- ?????????????override?public?function?set?label(value:String):void?{ ?
- ?????????????????super.label?=?value; ?
- ?????????????????labelDisplay.text?=?label;? ?
- ????????????} ?
- ?????????]]>?
-
?????</fx:Script>?
- ?? ?
-
?????<s:Rect?left="0"?right="0"?top="0"?bottom="0">?
-
?????????<s:stroke.normalAndShowsCaret>?
-
?????????????<s:SolidColorStroke?color="{selectionColor}"?weight="1"?/>?
-
?????????</s:stroke.normalAndShowsCaret>?
-
?????????<s:stroke.hoveredAndShowsCaret>?
-
?????????????<s:SolidColorStroke?color="{selectionColor}"?weight="1"?/>?
-
?????????</s:stroke.hoveredAndShowsCaret>?
-
?????????<s:stroke.selectedAndShowsCaret>?
-
?????????????<s:SolidColorStroke?color="{selectionColor}"?weight="1"?/>?
-
?????????</s:stroke.selectedAndShowsCaret>?
-
?????????<s:fill>?
-
?????????????<s:SolidColor?color.normal="{contentBackgroundColor}"?
-
?????????????????????color.normalAndShowsCaret="{contentBackgroundColor}"?
-
?????????????????????color.hovered="{rollOverColor}"???? ?
-
????????????????????color.hoveredAndShowsCaret="{rollOverColor}"?
-
?????????????????????color.selected="{selectionColor}"?
-
?????????????????????color.selectedAndShowsCaret="{selectionColor}"?/>?
-
?????????</s:fill>?
-
?????</s:Rect>?
- ?? ?
-
?????<s:Graphic?toolTip="{data.fontName}"?width="100%"?height="100%">?
-
?????????<s:SimpleText?id="labelDisplay"?
-
?????????????????fontFamily="{data.fontName}"?
-
?????????????????verticalCenter="0"?
-
?????????????????left="3"?right="3"?top="6"?bottom="4"/>?
-
?????</s:Graphic>?
- ?? ?
-
?</s:ItemRenderer>