加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex checkbox选择状态与未选择状态下更改图片或者颜色

发布时间:2020-12-15 01:13:40 所属栏目:百科 来源:网络整理
导读:前几天一qq群里哥们问一个checkbox style的问题,我就觉得反正自己也不会就直接在网上找了一篇帖子,发到这里来了。大家分享一下吧! ? xml version = " 1.0 " encoding = " utf-8 " ? mx:Application ? name = " CheckBox_color_test " ? ? ? ? xmlns:mx =

前几天一qq群里哥们问一个checkbox style的问题,我就觉得反正自己也不会就直接在网上找了一篇帖子,发到这里来了。大家分享一下吧!

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application?name="CheckBox_color_test"
  3. ? ? ? ? xmlns:mx="http://www.adobe.com/2006/mxml"
  4. ? ? ? ? layout="vertical"
  5. ? ? ? ? verticalAlign="middle"
  6. ? ? ? ? backgroundColor="white">
  7. ?
  8. ? ? <mx:Style>
  9. ? ? ? ? CheckBox {
  10. ? ? ? ? ? ? fontWeight: bold;
  11. ? ? ? ? ? ? iconColor: green;
  12. ? ? ? ? }
  13. ?
  14. ? ? ? ? .selectedStyle {
  15. ? ? ? ? ? ? color: green;
  16. ? ? ? ? ? ? textRollOverColor: green;
  17. ? ? ? ? ? ? textSelectedColor: green;
  18. ? ? ? ? ? ? themeColor: green;
  19. ? ? ? ? }
  20. ?
  21. ? ? ? ? .unselectedStyle {
  22. ? ? ? ? ? ? color: red;
  23. ? ? ? ? ? ? textRollOverColor: red;
  24. ? ? ? ? ? ? textSelectedColor: red;
  25. ? ? ? ? ? ? themeColor: red;
  26. ? ? ? ? }
  27. ? ? </mx:Style>
  28. ?
  29. ? ? <mx:Script>
  30. ? ? ? ? <![CDATA[
  31. ? ? ? ? ? ? private function checkBox_change(evt:Event):void {
  32. ? ? ? ? ? ? ? ? var tgt:CheckBox = evt.currentTarget as CheckBox;
  33. ? ? ? ? ? ? ? ? if (tgt.selected) {
  34. ? ? ? ? ? ? ? ? ? ? tgt.styleName = "selectedStyle";
  35. ? ? ? ? ? ? ? ? } else {
  36. ? ? ? ? ? ? ? ? ? ? tgt.styleName = "unselectedStyle";
  37. ? ? ? ? ? ? ? ? }
  38. ? ? ? ? ? ? }
  39. ? ? ? ? ]]>
  40. ? ? </mx:Script>
  41. ?
  42. ? ? <mx:CheckBox?id="checkBox"
  43. ? ? ? ? ? ? label="CheckBox"
  44. ? ? ? ? ? ? selected="false"
  45. ? ? ? ? ? ? styleName="unselectedStyle"
  46. ? ? ? ? ? ? change="checkBox_change(event);"?/>
  47. ?
  48. </mx:Application>

其实,这是说的checkbox如果是button或者其他的控件也可以。

<fx:Style>

  • ? ? ? ? ? ? ? ? @namespace s "library://ns.adobe.com/flex/spark";
  • ? ? ? ? ? ? ? ? @namespace mx "library://ns.adobe.com/flex/mx";
  • ? ? ? ? ? ? ? ? .myButton{
  • ? ? ? ? ? ? ? ?? ? icon:Embed(source="logo.gif");
  • ? ? ? ? ? ? ? ? }
  • ? ? ? ? </fx:Style>
    • <mx:Button x="449" y="26"??styleName="myButton"/>
  • (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读