Flex: invalidateData

I'm having problems updating my components when the parameters change:

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];
        }

    }
}

      

When I set from and to, the thumbs are not updated. I tried invalidateProperties but it didn't work.

0


source to share


1 answer


Add a call to invalidateDisplayList () after invalidateProperties (). This ensures that Flex redraws the component at the next keyframe.



You should also add the same to the set to () function.

+1


source







All Articles