Flex中如何利用drawRoundRectComplex函数描画出复合矩形的例子

By Minidxer | September 21, 2008

接下来的例子演示了Flex中如何利用drawRoundRectComplex函数,描画出复合矩形。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.         layout="vertical"
  4.         verticalAlign="middle"
  5.         backgroundColor="white"
  6.         creationComplete="init()">
  7.  
  8.     <mx:Script>
  9.         <![CDATA[
  10.             import mx.styles.StyleManager;
  11.             import mx.utils.GraphicsUtil;
  12.  
  13.             private var fillColor:uint;
  14.  
  15.             private function init():void {
  16.                 fillColor = StyleManager.getColorName("haloOrange");
  17.  
  18.                 box.graphics.clear();
  19.                 box.graphics.beginFill(fillColor);
  20.                 GraphicsUtil.drawRoundRectComplex(box.graphics,
  21.                                                     0,
  22.                                                     0,
  23.                                                     box.width,
  24.                                                     box.height,
  25.                                                     topLeft.value,
  26.                                                     topRight.value,
  27.                                                     bottomLeft.value,
  28.                                                     bottomRight.value);
  29.             }
  30.         ]]>
  31.     </mx:Script>
  32.  
  33.     <mx:ApplicationControlBar dock="true">
  34.         <mx:Form>
  35.             <mx:FormItem label="topLeft:">
  36.                 <mx:HSlider id="topLeft"
  37.                         minimum="0"
  38.                         maximum="{box.height / 2}"
  39.                         snapInterval="1"
  40.                         tickInterval="10"
  41.                         liveDragging="true"
  42.                         change="init();" />
  43.             </mx:FormItem>
  44.             <mx:FormItem label="topRight:">
  45.                 <mx:HSlider id="topRight"
  46.                         minimum="0"
  47.                         maximum="{box.height / 2}"
  48.                         snapInterval="1"
  49.                         tickInterval="10"
  50.                         liveDragging="true"
  51.                         change="init();" />
  52.             </mx:FormItem>
  53.             <mx:FormItem label="bottomLeft:">
  54.                 <mx:HSlider id="bottomLeft"
  55.                         minimum="0"
  56.                         maximum="{box.height / 2}"
  57.                         snapInterval="1"
  58.                         tickInterval="10"
  59.                         liveDragging="true"
  60.                         change="init();" />
  61.             </mx:FormItem>
  62.             <mx:FormItem label="bottomRight:">
  63.                 <mx:HSlider id="bottomRight"
  64.                         minimum="0"
  65.                         maximum="{box.height / 2}"
  66.                         snapInterval="1"
  67.                         tickInterval="10"
  68.                         liveDragging="true"
  69.                         change="init();" />
  70.             </mx:FormItem>
  71.         </mx:Form>
  72.     </mx:ApplicationControlBar>
  73.  
  74.     <mx:Box id="box" width="240" height="160" />
  75.  
  76. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Other | No Comments » | Tags: ,

Search Posts