咖啡伴侶

          呆在上海
          posts - 163, comments - 156, trackbacks - 0, articles - 2

          導(dǎo)航

          公告

          呆在上海 

          Java,F(xiàn)lex,Android,SVG等技術(shù)的 圖形UI

          Email:leooath@gmail.com

          QQ:35339893


          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          Flex ColorLabel 實現(xiàn)

          Posted on 2008-03-28 09:58 oathleo 閱讀(493) 評論(0)  編輯  收藏 所屬分類: Flex
          ?public class ColorLabel extends Label
          ?{
          ??private var colorValue:Number = -1;
          ??public function ColorLabel()
          ??{
          ???super();
          ??}
          ??
          ??public function setColorValue(colorValue:Number):void
          ??{
          ???this.colorValue = colorValue;
          ??}
          ??
          ??override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
          ???? {
          ??????????? super.updateDisplayList(unscaledWidth, unscaledHeight);
          ??????????? if(colorValue>=0){
          ??????????? ?drawColor(colorValue);
          ??????????? }
          ???? }
          ??
          ??private function drawColor(colorValue:Number):void
          ???? {
          ???? ?? this.graphics.beginFill(colorValue);
          ????????????? this.graphics.drawRect(this.textField.x,this.textField.y,this.textWidth ,this.textHeight);
          ????????????? this.graphics.endFill();
          ???? }
          ?}
          ?
          ?
          ?*? <p>In general, components do not override the <code>validateProperties()</code>,
          ?*? <code>validateSize()</code>, or <code>validateDisplayList()</code> methods
          .?
          ?*? In the case of UIComponents, most components override the
          ?*? <code>commitProperties()</code>, <code>measure()</code>, or
          ?*? <code>updateDisplayList()</code> methods
          , which are called
          ?*? by the <code>validateProperties()</code>,
          ?*? <code>validateSize()</code>, or
          ?*? <code>validateDisplayList()</code> methods, respectively.</p>
          ?
          ?

          ?

          Implementing the commitProperties() method

          You use the commitProperties() method to coordinate modifications to component properties. Most often, you use it with properties that affect how a component appears on the screen.

          Flex schedules a call to the commitProperties() method when a call to the invalidateProperties() method occurs. The commitProperties() method executes during the next render event after a call to the invalidateProperties() method. When you use the addChild() method to add a component to a container, Flex automatically calls the invalidateProperties() method.

          Calls to the commitProperties() method occur before calls to the measure() method. This lets you set property values that the measure() method might use.

          Implementing the measure() method

          The measure() method sets the default component size, in pixels, and optionally sets the component's default minimum size.

          Flex schedules a call to the measure() method when a call to the invalidateSize() method occurs. The measure() method executes during the next render event after a call to the invalidateSize() method. When you use the addChild() method to add a component to a container, Flex automatically calls the invalidateSize() method.

          Implementing the updateDisplayList() method

          The updateDisplayList() method sizes and positions the children of your component based on all previous property and style settings, and draws any skins or graphic elements that the component uses. The parent container for the component determines the size of the component itself.

          A component does not appear on the screen until its updateDisplayList() method gets called. Flex schedules a call to the updateDisplayList() method when a call to the invalidateDisplayList() method occurs. The updateDisplayList() method executes during the next render event after a call to the invalidateDisplayList() method. When you use the addChild() method to add a component to a container, Flex automatically calls the invalidateDisplayList() method.

          Drawing graphics in your component

          Every Flex component is a subclass of the Flash Sprite class, and therefore inherits the Sprite.graphics property. The Sprite.graphics property specifies a Graphics object that you can use to add vector drawings to your component.

          For example, in the updateDisplayList() method, you can use methods of the Graphics class to draw borders, rules, and other graphical elements:

          ?

          總結(jié):

          修改屬性用commitProperties,自己畫用updateDisplayList

          主站蜘蛛池模板: 澳门| 香格里拉县| 同德县| 修水县| 潮安县| 恭城| 高唐县| 綦江县| 交口县| 黄浦区| 东兰县| 临夏县| 扬州市| 仙居县| 鹤山市| 平乐县| 永顺县| 新泰市| 珲春市| 炎陵县| 灌阳县| 朝阳县| 大宁县| 志丹县| 巫山县| 原平市| 保山市| 达州市| 孙吴县| 康乐县| 海林市| 股票| 忻城县| 襄垣县| 尉氏县| 炉霍县| 新竹市| 鸡泽县| 阿拉善左旗| 乌鲁木齐县| 全南县|