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

flex titleWindow添加最小化和最大化按纽as

发布时间:2020-12-15 05:17:37 所属栏目:百科 来源:网络整理
导读:? pre ? name = "code" ? class = "html" package?com.talkyun.rheaui.model?? {?? //MyWindow作用是为titleWindow添加窗体的最小化和最大化的功能?? ?? ??import?flash.events.MouseEvent;?? ??import?mx.containers.TitleWindow;?? ??import?mx.controls.B
?
  1. <pre?name="code"?class="html">package?com.talkyun.rheaui.model??
  2. {??
  3. //MyWindow作用是为titleWindow添加窗体的最小化和最大化的功能??
  4. ??
  5. ??import?flash.events.MouseEvent;??
  6. ??import?mx.containers.TitleWindow;??
  7. ??import?mx.controls.Button;??
  8. ??
  9. ??
  10. ??public?class?MyWindow?extends?TitleWindow??
  11. ??{??
  12. ????public?function?MyWindow()??
  13. ????{??
  14. ??????super();??
  15. ??????this.showCloseButton=true;??
  16. ????}??
  17. ????protected?var?maxSizeButton:Button;?//最大化按钮??
  18. ????protected?var?minSizeButton:Button;?//最小化按钮??
  19. ?????
  20. ????//正常状态下窗口的大小、位置??
  21. ????protected?var?normalX:int,normalY:Number,normalWidth:int,normalHeight:int;??
  22. ?????
  23. ????//初始状态??
  24. ????protected?var?winState:String="normal";??
  25. ?????
  26. ????override?protected?function?createChildren():void??
  27. ????{??
  28. ??????super.createChildren();??
  29. ???????
  30. ??????//创建最大化按钮??
  31. ??????this.maxSizeButton=new?Button();??
  32. ??????thisthis.maxSizeButton.width=this.maxSizeButton.height=16;??
  33. ??????this.maxSizeButton.y=6;??
  34. ??????//添加最大化事件??
  35. ??????this.maxSizeButton.addEventListener(MouseEvent.CLICK,OnMaxSize);??
  36. ??????this.titleBar.addChild(this.maxSizeButton);??
  37. ???????
  38. ??????//创建最小化按钮??
  39. ??????this.minSizeButton=new?Button();??
  40. ??????thisthis.minSizeButton.width=this.minSizeButton.height=16;??
  41. ??????this.minSizeButton.y=6;??
  42. ??????//添加最小化事件??
  43. ??????this.minSizeButton.addEventListener(MouseEvent.CLICK,OnMinSize);??
  44. ??????this.titleBar.addChild(this.minSizeButton);??
  45. ????}??
  46. ????protected?function?OnMaxSize(e:MouseEvent):void??
  47. ????{??
  48. ??????if(winState=="normal")??
  49. ??????{??
  50. ????????//保存正常状态下窗口位置、大小??
  51. ????????normalX=this.x;??
  52. ????????normalY=this.y;??
  53. ????????normalHeight=this.height;??
  54. ????????normalWidth=this.width;??
  55. ?????????
  56. ????????//设置为最大化状态??
  57. ????????this.x=0;??
  58. ????????this.y=0;??
  59. ?????????
  60. ????????this.percentHeight=1200;??
  61. ????????this.percentWidth=1000;??
  62. ?????????
  63. ????????//最大化状态??
  64. ????????this.winState="max";??
  65. ??????}??
  66. ??????else?if(this.winState=="max")??
  67. ??????{??
  68. ????????//恢复正常状态下窗口位置、大小??
  69. ????????thisthis.x=this.normalX;??
  70. ????????thisthis.y=this.normalY;??
  71. ????????thisthis.width=this.normalWidth;??
  72. ????????thisthis.height=this.normalHeight;??
  73. ?????????
  74. ????????//正常状态??
  75. ????????this.winState="normal";??
  76. ??????}??
  77. ????}??
  78. ????protected?function?OnMinSize(e:MouseEvent):void??
  79. ????{??
  80. ??????//最小化,简单隐藏??
  81. ?????????this.visible=false;??
  82. ????}??
  83. ????override?protected?function?layoutChrome(unscaledWidth:Number,??
  84. ?????????????????????????????????????????????unscaledHeight:Number):void??
  85. ????{??
  86. ??????super.layoutChrome(unscaledWidth,unscaledHeight);??
  87. ??????//设置两个新添的按钮的位置??
  88. ??????thisthis.maxSizeButton.x=this.titleBar.width-43;??
  89. ??????thisthis.minSizeButton.x=this.titleBar.width-60;??
  90. ???????
  91. ??????//调整状态文本的位置,左移一段位置??
  92. ??????this.statusTextField.x-=32;??
  93. ????}??
  94. ??}???
  95. }??

(编辑:李大同)

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

    推荐文章
      热点阅读