      */
     public function set viewport(value:IViewport):void
     {
+        if (value == _viewport)
+            return;
+            
+        if (_viewport)  // old _viewport
+        {
+            _viewport.removeEventListener(PropertyChangeEvent.PROPERTY_CHANGE, viewport_propertyChangeHandler);
+            _viewport.removeEventListener(ResizeEvent.RESIZE, viewportResizeHandler);
+        }
+
         _viewport = value;
-    }    
+
+        if (_viewport)  // new _viewport
+        {
+            _viewport.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, viewport_propertyChangeHandler);
+            _viewport.addEventListener(ResizeEvent.RESIZE, viewportResizeHandler);
+        }
+    }
     
     //--------------------------------------------------------------------------
     //

    //
    //--------------------------------------------------------------------------

    //---------------------------------
    // Mouse up/down handlers
    //---------------------------------

import flash.utils.Timer;
import mx.components.FxButton;
import mx.core.IViewport;
import mx.events.PropertyChangeEvent;
import mx.events.ResizeEvent;

/**
 *  The FxScrollBar class helps to position
