通过as3代码定义ToggleButtonBar的选中时的样式
直接上代码:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" layout="absolute" width="600" height="500" creationComplete="init();"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; [Bindable] private var colArr:ArrayCollection=new ArrayCollection(["你好","Geloo"]); private function init():void { var newCss:CSSStyleDeclaration=new CSSStyleDeclaration(".bbs"); newCss.defaultFactory=function():void { this.color=0xff0000; this.disabledColor=0xff000f; this.textRollOverColor=0xfff000; this.fontWeight="bold"; } StyleManager.setStyleDeclaration(".bbs",newCss,true); bar.setStyle("selectedButtonTextStyleName","bbs"); } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <mx:Button x="34" y="40" label="按钮"/> <mx:ToggleButtonBar id="bar" x="34" y="70" dataProvider="{colArr}" selectedIndex="0"/> </mx:Application> |
评论
您的评论出现需要一些时间,请不要重复提交。