用于缩放轮廓的交互式滑块
我正在尝试构建一个交互式滑块,其中当用户向上拖动滑块时,轮廓的高度会增加一些固定量,当用户向下拖动滑块时,轮廓的高度会减少一些固定量。
我面临的问题是,当我缓慢拖动滑块时,一切正常,但是当我拖动滑块比高度快时,不能正确增加或减少。我的意思是轮廓高度的增量或减量取决于滑块的速度,我不想要。
这是代码-
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
改变
to
its more accurate for detecting that kind of stuff
change the
to
its more accurate for detecting that kind of stuff