views:

88

answers:

1

I've trouble getting my components to update when the params has changed:

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 aren't updating. I've tried invalidateProperties but that didn't work.

+1  A: 

Add a call to invalidateDisplayList() after invalidateProperties(). That will ensure that Flex redraws the component on the next keyframe.

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

Spikefu