Flex 4.0 之commitProperties函數的使用

來源:互聯網
上載者:User

commitProperties ()
方法  

override protected function commitProperties():void

 
處理對組件設定的屬性。此方法是一種進階方法,可在建立 UIComponent 的子類時覆蓋。
您無需直接調用此方法,當您使用 addChild() 方法向容器中添加組件時,或調用組件的 invalidateProperties() 方法時,Flex 都會調用 commitProperties() 方法。應在調用 measure() 方法之前調用 commitProperties() 方法。這允許您設定 measure() 方法可能會用到的屬性值。

一些組件的屬性可能會影響需要建立的子物件的數目或種類,也有些組件的屬性彼此之間會相互影響(例如 horizontalScrollPolicy 和 horizontalScrollPosition 屬性)。通常,最好在啟動時一次性處理所有這些屬性以避免重複工作。

範例:

一些組件的屬性可能會影響需要建立的子物件的數目或種類,也有些組件的屬性彼此之間會相互影響(例如 horizontalScrollPolicy 和 horizontalScrollPosition 屬性)。通常,最好在啟動時一次性處理所有這些屬性以避免重複工作。

import flash.filters.GlowFilter;
 import flash.text.TextFormat;
 
 import mx.controls.Label;
 
 public class MyLabel extends Label
 {
  private var _color:uint;
  public function MyLabel()
  {
   super();
  }
  override protected function commitProperties():void 
  {  
   super.commitProperties();  
   var glow:GlowFilter = new GlowFilter(_color,1,2,2,255,1,false);  
   var arr:Array = new Array();  
   arr.push(glow);  
   this.textField.filters = arr;  
  }
    
  public function set stroke(color:uint):void
  {
   _color=color;
  }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.