I have a scroll bar. I want to program it so that if you mouse up anywhere that it stops. (Rather than having to mouse up directly over the scroll bar.) I remember there being a simple solution for this, but I don’t remember what that solution was.
package
{
import flash.display.MovieClip
import flash.geom.Rectangle;
import flash.events.*;
public class HolmanScrollBar extends MovieClip
{
public function HolmanScrollBar(barHeight:Number, target:MovieClip = null):void
{
bar_mc.y = handle_mc.y = upArrow_btn.height+10;
bar_mc.height = barHeight - (bar_mc.y * 2)
downArrow_btn.y = bar_mc.y + bar_mc.height + 10 + downArrow_btn.height;
handle_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragHandle);
handle_mc.addEventListener(MouseEvent.MOUSE_UP, stopDragHandle);
if(target != null)
{
}
}
private function dragHandle(e:MouseEvent):void
{
handle_mc.startDrag(false, new Rectangle(bar_mc.x+.5, bar_mc.y, 0, bar_mc.height-handle_mc.height));
}
private function stopDragHandle(e:MouseEvent):void
{
handle_mc.stopDrag();
}
}
}