用于缩放轮廓的交互式滑块

发布于 2024-11-08 01:19:00 字数 1424 浏览 0 评论 0原文

我正在尝试构建一个交互式滑块,其中当用户向上拖动滑块时,轮廓的高度会增加一些固定量,当用户向下拖动滑块时,轮廓的高度会减少一些固定量。

我面临的问题是,当我缓慢拖动滑块时,一切正常,但是当我拖动滑块比高度快时,不能正确增加或减少。我的意思是轮廓高度的增量或减量取决于滑块的速度,我不想要。

这是代码-

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 slider 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.";
}

 }

谢谢 库什万特

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 slider 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风苍溪 2024-11-15 01:19:00

改变

MouseEvent.MOUSE_MOVE

to

Event.ENTER_FRAME

its more accurate for detecting that kind of stuff

change the

MouseEvent.MOUSE_MOVE

to

Event.ENTER_FRAME

its more accurate for detecting that kind of stuff

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文