Вход

Просмотр полной версии : Регулятор Скорости Вращения.


warning1
12.10.2014, 16:06
dragger.onPress = function() {
this.startDrag(true, 0, 0, line._width, 0);
this.onEnterFrame = function() {
ratio = Math.round(this._x*100/line._width);
_root.volume = ratio;
};
};
dragger.onRelease = dragger.onreleaseOutside=stopDrag;


triangle.onEnterFrame = function() {
this._rotation += 0.1;
};

Я надыбал где-то 2 кода, 1 - на регулятор, а второй на вращение.

Не хочется опять делать куча кейфреймов. Хочется сделать нормальный код.

Вообщем как правильно объединить их чтобы ползунок регулировал скорость вращения мувиклипа.

Спасибо.

warning1
12.10.2014, 18:13
_root.triangle.onEnterFrame = function() {
_root.triangle._rotation += 1;
};

this.ratio = 0;

dragger.onPress = function() {
this.startDrag(true, 0, 0, line._width, 0);
this.onEnterFrame = function() {
ratio = Math.round(this._x*360/line._width);
_root.triangle._rotation = ratio;
};
};
dragger.onRelease = dragger.onreleaseOutside=stopDrag;


Вот такой код. Только у меня выходит на ускорять\замедлять вращение а крутить от руки.

Я в этом дуб дерево - не пойму как и что )

Дайте совета чтоли.

Исходник прикрепил.

samana
12.10.2014, 18:42
Можно так
var speed:Number=0;

_root.triangle.onEnterFrame = function() {
_root.triangle._rotation += speed;
};

dragger.onPress = function() {
this.startDrag(true, 0, 0, line._width, 0);
this.onEnterFrame = function() {
speed = Math.round((this._x-line._x)*0.1);
};
};
dragger.onRelease = dragger.onReleaseOutside =function(){
stopDrag();
delete dragger.onEnterFrame;
}

warning1
13.10.2014, 05:53
Отлично! Спасибо, то что нужно.

Добавлено через 24 часа 57 минут
Ещё бы неплохо сделать регулятор оттенка (hue).

Насколько я понял в as2 нет прямого доступа к adjust color.

С регулятором прозрачности (alpha) разобрался. Вот код:

this.ratio = 0;
dragger.onPress = function() {
this.startDrag(true, 0, 0, line._width, 0);
this.onEnterFrame = function() {
ratio = Math.round(this._x*100/line._width);
_root.triangle._alpha = ratio;
};
};
dragger.onRelease = dragger.onreleaseOutside=stopDrag;

Как сделать по образу и подобию ?

Добавлено через 36 часов 59 минут

warning1
16.10.2014, 18:41
Нашёл код для изменения оттенка:

onClipEvent(load){
//Import the classes needed to transform the color
import flash.geom.ColorTransform;
import flash.geom.Transform;
//A starting amount to tint the image
redamount = 0;
//Is the image getting more red or more blue?
goingred = true;
}
//Run at the start of each frame
onClipEvent(enterFrame) {
//if going red is set to true, set the color transform to tint the image more red
if (goingred) {
redamount++;
//otherwise, it is getting more blue
} else {
redamount--;
}
//the boundaries. If a limit (0 or 64) has been reached, flip from going red to going blue
if (redamount == 0 || redamount == 64) {
goingred = !goingred;
}
//Declare a new ColorTransform object
var colorTrans:ColorTransform = new ColorTransform();
//Set the red offset to the specified amount. Higher is stronger
colorTrans.redOffset = redamount;
//when the red offset is low, the blue offset is high, and vice versa.
colorTrans.blueOffset = 64-redamount;
//Create a new Transform object. This is attached to the movieclip 'tintedimage'
var trans:Transform = new Transform(this);
//apply the color transform to the transform object
trans.colorTransform = colorTrans;
}

Как объединить с предыдущим ? (засунуть в слайдер).

warning1
24.10.2014, 11:33
Чё, никто не знает ?

razve
25.10.2014, 10:46
Чё, никто не знает ?
Потому что слишком просто. Эти обработчики событий говорят где нужно разместить код.
onClipEvent(load){}
onClipEvent(enterFrame) {}

warning1
29.10.2014, 06:51
Вы немного не поняли вопроса.

Нужно 3 разных регулятора, а впрочем.

Флешка уже доделана, - вот тут кому интересно:

http://www.flasher.ru/forum/showthread.php?p=1174287#post1174287

razve
29.10.2014, 09:45
Флэшка не доделана, все-таки регулятор оттенков ты так и не прикрутил :)
А количество регуляторов не имеет значения, если ты понимаешь где разместить код, вышеуказанные обработчики событий - это же самые азы.
Еще есть замечание по регулятору: он ни на что не реагирует на первых 10% начала вращения и останавливает вращение за 10% до сдвига в начальное положение ползунка. Приплюсуй тройку и будет норм.
speed = Math.round((this._x-line._x+3)*0.1);
Флэшка с тремя регуляторами.

warning1
29.10.2014, 11:56
Спасибо, очень ценный для меня код. Очень что-то он мне трудно даёться.

Программу обновлю и доделаю немного.