开发者

Interactive slider for scaling a silhouette

开发者 https://www.devze.com 2023-03-06 19:26 出处:网络
I am trying to build a interactive slider,in which when user drag the slider up the height of silhouette increases by some fix amount n when user dragthe slider down the height of silhouette decreases

I am trying to build a interactive slider,in which when user drag the slider up the height of silhouette increases by some fix amount n when user drag the slider down the height of silhouette decreases by some fix amount.

the problem i am facing is that when i drag the slider slowly than everything works fine but when i drag the slider faster than the height dont increase or decrease properly.i mean the increment or decrement in the height of silhouette is depending on speed of slider,which i dnt want.

here is the code-

var bounds:Rectangle = new Rectangle(499.65,260,0,240);

slider.addEventListener(MouseEvent.MOUSE_DOWN, moveSlider);
stage.addEventListener(MouseEvent.MOUSE_UP, stopSlider);

/*****Function to move slider of height bar*****/

function moveSlider(Event:MouseEvent)
{
slider.startDrag(false,bounds);
stage.addEventListener(MouseEvent.MOUSE_MOVE, changeHeight);
slider.removeEventListener(MouseEvent.MOUSE_DOWN, moveSlider);
stage.addEventListener(MouseEvent.MOUSE_UP, stopSlider);
}


/*****Function to stop slid开发者_如何学JAVAer of height bar*****/

function stopSlider(Event:MouseEvent)
{
slider.stopDrag();
slider.addEventListener(MouseEvent.MOUSE_DOWN, moveSlider);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, changeHeight);
stage.removeEventListener(MouseEvent.MOUSE_UP, stopSlider);
}


/*****Function to increase height & change values in height text box*****/

function changeHeight(Event:MouseEvent)
 {

if(mouseY > 260 && mouseY < 500)
{

d = 500 - mouseY;
var m:Number = d % factor;
model_height.scaleY += .002;
model_height.scaleX += .002;

if (m == 0)
{
    i++;

}

if (i > 11)
{
    f++;
    i = 0;
}

inches = i;
height_bottom_txt.text = f + "ft." + " " + inches + " " + "in.";
}

 }

Thanks Khushwant


change the

MouseEvent.MOUSE_MOVE
to
Event.ENTER_FRAME
its more accurate for detecting that kind of stuff

0

精彩评论

暂无评论...
验证码 换一张
取 消