title: as3 simple slider
body: <p>My goal is tio buid a simpleslider in as3
  This nearly works.. but the only trouble is: 
  when you click drag the slider and you go out from the track, the slider is still being dragged.</p>
  
  <p>I guess there is a simple trick to prevent that nasty effect</p>
  
  <pre><code>package  {
  import flash.display.MovieClip;
  import flash.events.MouseEvent;
  import flash.geom.Rectangle; public class SliderH extends MovieClip {
      public function SliderH() {
          trace("creation");
          addEventListener(MouseEvent.MOUSE_DOWN, mousedown);
          addEventListener(MouseEvent.MOUSE_UP, mouseup);
          this.buttonMode = true;
      }
      private function mousedown(e:MouseEvent):void {
          trace("begin");
          var rect:Rectangle = new Rectangle(-this.parent.width/2,0,this.parent.width,0);
          startDrag(false , rect);
  
      }
      private function mouseup(e:MouseEvent):void {
          stopDrag();
          trace(this.x);
      }       
  }
  </code></pre>
  
  <p>}</p>