PDA

View Full Version : help with a slider


rondog
12-18-2008, 11:12 PM
I am trying to make a volume slider and I cant seem to get it to work when the user clicks, holds and drags. It works as long as your mouse is inside the movieclip, but anywhere else it just freezes. Look here to see what I am talking about: http://ronnieswietek.com/hosted/flvplayer/test.html

Here is my code that handles when the user interacts with that volume slider:

controls.volmc.addEventListener(MouseEvent.MOUSE_D OWN, startDragging);
controls.volmc.addEventListener(MouseEvent.MOUSE_U P, stopDragging);

private function startDragging(e:MouseEvent):void
{
controls.volmc.addEventListener(MouseEvent.MOUSE_M OVE, updateVolBySlide);
var pct:Number = e.localX / volWidth;
volBar.width = e.localX;
}

private function stopDragging(e:MouseEvent):void
{
controls.volmc.removeEventListener(MouseEvent.MOUS E_MOVE, updateVolBySlide);
}

private function updateVolBySlide(e:MouseEvent):void
{
volBar.width = e.localX;
}

Dail
12-19-2008, 10:00 PM
Best to add your mouseMove to the stage along with your mouseUp, that way releases outside of your dragger will be caught correctly.

Just make sure you remove those listeners that are referencing the stage when you dispose of your class, or you will get issues with stranded listeners etc.