製作一個簡單的應用程序,其中包含一個可更改文本框值的滑塊,但每當我放下滑塊時,它都會回到其0位置。我需要它留在原地。請幫忙!AS3拖動總是回到原來的位置?
代碼:
theroot.settings_but.phone1.slider.addEventListener(MouseEvent.MOUSE_DOWN, slide);
public function slide(e:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_UP, dragstop);
var bounds:Rectangle = new Rectangle(0,27,550,0);
theroot.settings_but.phone1.slider.startDrag(false, bounds);
txtboxint = setInterval(changetextbox, 500);
}
public function dragstop(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_UP, dragstop);
clearInterval(txtboxint);
trace("what", e.target.x, e.currentTarget, e.target.name) // returns proper x value, [object Stage], slider
trace("almost", theroot.settings_but.phone1.slider.x);// returns proper x value
theroot.settings_but.phone1.slider.stopDrag();
trace("last", theroot.settings_but.phone1.slider.x); //returns proper x value
}
public function changetextbox():void
{
trace(theroot.settings_but.phone1.slider.x) //returns proper x value
theroot.settings_but.phone1txt.text = (Math.floor(((theroot.settings_but.phone1.slider.x)/550) * 40));
}
我認爲它必須在代碼中的其他地方出現問題。這看起來很好。 – imcg