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

时间:2011-05-17 19:24:39

标签: flash actionscript-3 flash-cs5 scale

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

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

这是代码 -

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

 }

由于 Khushwant

1 个答案:

答案 0 :(得分:0)

MouseEvent.MOUSE_MOVE
更改为
Event.ENTER_FRAME
它更准确地检测那种东西