actionscript自定义组件,属性:
- package?contr ?
- { ?
- ????import?spark.components.BorderContainer; ?
- ???? ?
- ????public?class?Ruler?extends?BorderContainer ?
- ????{ ?
- ????????private?var?_lineLength:Number; ?
- ???????? ?
- ????????private?var?_spacing:Number; ?
- ????????private?var?_scale:Number; ?
- ???????? ?
- ????????public?function?Ruler() ?
- ????????{ ?
- ????????????super(); ?
- ????????} ?
- ?
- ????????/**定义最小显示刻度*/ ?
- ????????public?function?get?scale():Number ?
- ????????{ ?
- ????????????return?_scale; ?
- ????????} ?
- ?
- ????????/** ?
- ?????????*?@private ?
- ?????????*/ ?
- ????????public?function?set?scale(value:Number):void ?
- ????????{ ?
-
????????????_scale?=?value; ?
- ????????} ?
- ?
- ????????/**定义最小间距*/ ?
- ????????public?function?get?spacing():Number ?
- ????????{ ?
- ????????????return?_spacing; ?
- ????????} ?
- ?
- ????????/** ?
- ?????????*?@private ?
- ?????????*/ ?
- ????????public?function?set?spacing(value:Number):void ?
- ????????{ ?
-
????????????_spacing?=?value; ?
- ????????} ?
- ?
- ????????/**定义线条的长度*/ ?
- ????????public?function?get?lineLength():Number ?
- ????????{ ?
- ????????????return?_lineLength; ?
- ????????} ?
- ?
- ????????/** ?
- ?????????*?@private ?
- ?????????*/ ?
- ????????public?function?set?lineLength(value:Number):void ?
- ????????{ ?
-
????????????_lineLength?=?value; ?
- ????????} ?
- ?
- ????} ?
- }?
效果:
- <?xml?version="1.0"?encoding="utf-8"?>?
-
<s:Application?xmlns:fx="http://ns.adobe.com/mxml/2009"? ?
-
???????????????xmlns:s="library://ns.adobe.com/flex/spark"? ?
-
???????????????xmlns:mx="library://ns.adobe.com/flex/mx"? ?
-
???????????????xmlns:con="contr.*"?
-
???????????????minWidth="955"?minHeight="600">?
-
????<fx:Declarations>?
-
?????????
-
????</fx:Declarations>?
-
????<mx:VBox?width="100%"?height="100%"?>?
-
????????<con:Ruler?lineLength="200"?scale="5" spacing="10"/>?
-
????</mx:VBox>?
-
</s:Application>?
?
