2008-12-15 67 views
0

我有麻煩我的部件時PARAMS已更改爲更新:軟硬度:invalidateData

package mycompany 
{ 

    import flash.events.Event; 
    import mx.events.SliderEvent; 
    import mx.controls.HSlider; 
    import mx.controls.sliderClasses.Slider; 

    public class FromToSlider extends HSlider 
    { 

     /* from: */ 

     private var _from:int; 

     [Bindable] 
     public function get from():int 
     { 
      return _from; 
     } 

     public function set from(value:int):void 
     { 
      this._from = value; 
      this.values[0] = value; 
      invalidateProperties(); 
     } 

     /* //from */ 

     /* to: */ 

     private var _to:int; 

     [Bindable] 
     public function get to():int 
     { 
      return _to; 
     } 

     public function set to(value:int):void 
     { 
      this._to = value; 
      this.values[1] = value; 
     } 

     /* //to */ 

     override public function initialize():void 
     { 
      super.initialize(); 
      addEventListener(SliderEvent.CHANGE, handleChange, false, 0, true); 
     } 

     protected function handleChange(event:SliderEvent):void 
     { 
      var ct:Slider=Slider(event.currentTarget); 
      this.from = ct.values[0]; 
      this.to = ct.values[1]; 
     } 

    } 
} 

當我設置「從」和「到」拇指沒有更新。我試過invalidateProperties,但沒有奏效。

回答

1

在invalidateProperties()後添加對invalidateDisplayList()的調用。這將確保Flex在下一個關鍵幀上重繪組件。

您還應該在'set to()'函數中添加相同的內容。