Эта проблема все еще возникает, и я не думаю, что ее можно избежать, но я использую другую функцию (Slider_checker
), которая запускается раз в 20 мс после простоя мыши, каждый раз, когда мышь прокручивает полосу прокрутки (20 мс позволяет ейвсе циклы Food_Scroll_ratio закончены, поэтому ничто не мешает и не сохраняет некоторые циклы процессора.
Вот мой окончательный код:
onClipEvent (load) {
Symptoms_sliders = new Array(this._parent.slider1.slider, this._parent.slider2.slider, this._parent.slider3.slider, this._parent.slider4.slider, this._parent.slider5.slider);
Food_sliders = new Array(this._parent.slider6.slider, this._parent.slider7.slider, this._parent.slider8.slider, this._parent.slider9.slider);
for (i=0; i<Food_sliders.length; i++) {
Food_sliders[i]._y = 75;
}
is_scrolling = 0;
Slider_check_interval = 0;
var mouseTimerID:Number;
var delay:Number = 50;
var mouseMoveListener = new Object();
mouseMoveListener.onMouseMove = function() {
clearInterval(mouseTimerID);
mouseTimerID = setInterval(Slider_checker, delay);
};
Slider_checker = function () {
while (Slider_check_interval == 1) {
count = 0;
for (i=0; i<Food_sliders.length; i++) {
count += 100-Food_sliders[i]._y;
}
if (count != 100 && count != 0) {
mxm = Food_sliders[0];
for (i=0; i<Food_sliders.length; i++) {
if (Food_sliders[i]._y<mxm._y) {
mxm = Food_sliders[i];
}
}
if (count>100) {
mxm._y += count-100;
}
if (count<100) {
mxm._y -= 100-count;
}
}
Slider_check_interval = 0;
}
};
Mouse.addListener(mouseMoveListener);
function Food_scroll_ratio() {
init_scroll_diff = init_scroll_num-init_scroll._y;
totalLeft = init_scroll_num;
Slider_check = new Array();
for (i=0; i<Food_sliders.length; i++) {
if (Food_sliders[i] != init_scroll) {
slider_pos = Food_sliders[i]._y;
percentageOf = ((100-init_slider_pos[i])/totalLeft)*100;
percentageMultiplier = 100/percentageOf;
if (init_scroll_num == 0) {
scroll_change = Math.round(Math.abs(init_scroll_diff/3));
} else {
scroll_change = Math.round(Math.abs(init_scroll_diff)/percentageMultiplier);
}
if (percentageOf == Infinity) {
Food_sliders[i]._y = 100;
} else if (init_scroll_diff>0) {
Food_sliders[i]._y = init_slider_pos[i]+scroll_change;
} else if (init_scroll_diff<0) {
Food_sliders[i]._y = init_slider_pos[i]-scroll_change;
}
}
}
Slider_check_interval = 1;
}
}
onClipEvent (mouseMove) {
for (i=0; i<Food_sliders.length; i++) {
Food_sliders[i].onPress = function() {
startDrag(this, false, 0, 100, 0, 0);
init_scroll_num = this._y;
init_scroll = this;
is_scrolling = 1;
init_slider_pos = new Array();
init_slider_pos.push(Food_sliders[0]._y);
init_slider_pos.push(Food_sliders[1]._y);
init_slider_pos.push(Food_sliders[2]._y);
init_slider_pos.push(Food_sliders[3]._y);
};
Food_sliders[i].onRelease = Food_sliders[i].onReleaseOutside=function () {
stopDrag();
is_scrolling = 0;
};
}
if (is_scrolling == 1) {
Food_scroll_ratio();
}
}