flex4 的DropdownList下拉框组件本身并不支持下拉框图片,但是可以结合条目渲染器和皮肤使其显示图片。
dropdownlist皮肤代码: flex/spark" xmlns:fb="http://ns.adobe.com/flashbuilder/2009" alpha.disabled=".5" xmlns:mx="library://ns.adobe.com/flex/mx"> style. */ static private const contentFill:Array=["bgFill"]; /** * @private */ override public function get contentItems():Array { return contentFill } ; /** * @private */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { if (getStyle("borderVisible") == false) { if (border) border.visible=false; if (background) { background.left=background.top=background.right=ba ckground.bottom=0; } if (scroller) scroller.minViewportInset=0; } else { if (border) border.visible=true; if (background) { background.left=background.top=background.right=ba ckground.bottom=1; } if (scroller) scroller.minViewportInset=1; } if (dropShadow) dropShadow.visible=getStyle("dropShadowVisible"); openButton.setStyle("cornerRadius", getStyle("cornerRadius")); if (borderStroke) { borderStroke.color=getStyle("borderColor"); borderStroke.alpha=getStyle("borderAlpha"); } super.updateDisplayList(unscaledWidth, unscaledHeight); } ]]--> In a custom skin class that uses transitions, set the itemDestructionPolicy property to none. --> 条目渲染器: flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" autoDrawBackground="true" creationComplete="itemrenderer1_creationCompleteHa ndler(event)"> 其使用代码: positionDDL.setStyle("skinClass", DropdownListSkin); positionArray=new ArrayCollection([{label: "最前", source: "../resources/bringtofront.png"}, {label: "前移", source: "../resources/bringforward.png"}, {label: "后移", source: "../resources/sendbackward.png"}, {label: "最后", source: "../resources/sendtoback.png"}]) positionDDL.dataProvider=positionArray; positionDDL.selectedIndex=0;
dropdownlist皮肤代码: flex/spark" xmlns:fb="http://ns.adobe.com/flashbuilder/2009" alpha.disabled=".5" xmlns:mx="library://ns.adobe.com/flex/mx"> style. */ static private const contentFill:Array=["bgFill"]; /** * @private */ override public function get contentItems():Array { return contentFill } ; /** * @private */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { if (getStyle("borderVisible") == false) { if (border) border.visible=false; if (background) { background.left=background.top=background.right=ba ckground.bottom=0; } if (scroller) scroller.minViewportInset=0; } else { if (border) border.visible=true; if (background) { background.left=background.top=background.right=ba ckground.bottom=1; } if (scroller) scroller.minViewportInset=1; } if (dropShadow) dropShadow.visible=getStyle("dropShadowVisible"); openButton.setStyle("cornerRadius", getStyle("cornerRadius")); if (borderStroke) { borderStroke.color=getStyle("borderColor"); borderStroke.alpha=getStyle("borderAlpha"); } super.updateDisplayList(unscaledWidth, unscaledHeight); } ]]--> In a custom skin class that uses transitions, set the itemDestructionPolicy property to none. --> 条目渲染器: flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" autoDrawBackground="true" creationComplete="itemrenderer1_creationCompleteHa ndler(event)"> 其使用代码: positionDDL.setStyle("skinClass", DropdownListSkin); positionArray=new ArrayCollection([{label: "最前", source: "../resources/bringtofront.png"}, {label: "前移", source: "../resources/bringforward.png"}, {label: "后移", source: "../resources/sendbackward.png"}, {label: "最后", source: "../resources/sendtoback.png"}]) positionDDL.dataProvider=positionArray; positionDDL.selectedIndex=0;