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

flex 学习笔记 as自定义组件(三)

发布时间:2020-12-15 04:56:23 所属栏目:百科 来源:网络整理
导读:actionscript自定义组件,属性: package?contr ? { ? ????import?spark.components.BorderContainer; ? ???? ? ????public?class?Ruler?extends?BorderContainer ? ????{ ? ????????private?var?_lineLength:Number; ? ???????? ? ????????private?var?_spa

actionscript自定义组件,属性:

 
 
  1. package?contr ?
  2. { ?
  3. ????import?spark.components.BorderContainer; ?
  4. ???? ?
  5. ????public?class?Ruler?extends?BorderContainer ?
  6. ????{ ?
  7. ????????private?var?_lineLength:Number; ?
  8. ???????? ?
  9. ????????private?var?_spacing:Number; ?
  10. ????????private?var?_scale:Number; ?
  11. ???????? ?
  12. ????????public?function?Ruler() ?
  13. ????????{ ?
  14. ????????????super(); ?
  15. ????????} ?
  16. ?
  17. ????????/**定义最小显示刻度*/ ?
  18. ????????public?function?get?scale():Number ?
  19. ????????{ ?
  20. ????????????return?_scale; ?
  21. ????????} ?
  22. ?
  23. ????????/** ?
  24. ?????????*?@private ?
  25. ?????????*/ ?
  26. ????????public?function?set?scale(value:Number):void ?
  27. ????????{ ?
  28. ????????????_scale?=?value; ?
  29. ????????} ?
  30. ?
  31. ????????/**定义最小间距*/ ?
  32. ????????public?function?get?spacing():Number ?
  33. ????????{ ?
  34. ????????????return?_spacing; ?
  35. ????????} ?
  36. ?
  37. ????????/** ?
  38. ?????????*?@private ?
  39. ?????????*/ ?
  40. ????????public?function?set?spacing(value:Number):void ?
  41. ????????{ ?
  42. ????????????_spacing?=?value; ?
  43. ????????} ?
  44. ?
  45. ????????/**定义线条的长度*/ ?
  46. ????????public?function?get?lineLength():Number ?
  47. ????????{ ?
  48. ????????????return?_lineLength; ?
  49. ????????} ?
  50. ?
  51. ????????/** ?
  52. ?????????*?@private ?
  53. ?????????*/ ?
  54. ????????public?function?set?lineLength(value:Number):void ?
  55. ????????{ ?
  56. ????????????_lineLength?=?value; ?
  57. ????????} ?
  58. ?
  59. ????} ?
  60. }?

效果:

 
 
  1. <?xml?version="1.0"?encoding="utf-8"?>?
  2. <s:Application?xmlns:fx="http://ns.adobe.com/mxml/2009"? ?
  3. ???????????????xmlns:s="library://ns.adobe.com/flex/spark"? ?
  4. ???????????????xmlns:mx="library://ns.adobe.com/flex/mx"? ?
  5. ???????????????xmlns:con="contr.*"?
  6. ???????????????minWidth="955"?minHeight="600">?
  7. ????<fx:Declarations>?
  8. ????????<!--?将非可视元素(例如服务、值对象)放在此处?-->?
  9. ????</fx:Declarations>?
  10. ????<mx:VBox?width="100%"?height="100%"?>?
  11. ????????<con:Ruler?lineLength="200"?scale="5" spacing="10"/>?
  12. ????</mx:VBox>?
  13. </s:Application>?

?

(编辑:李大同)

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

    推荐文章
      热点阅读