PDA

Просмотр полной версии : кривой API


Mr. Fixit
21.03.2007, 01:07
почему lines_mc начинается с нуля..:boredom:
_root.createEmptyMovieClip ('lines_mc', 0);
lines_mc.lineStyle (1);
onEnterFrame = function () {
//lines_mc.clear ();
lines_mc.moveTo (100, 100);
lines_mc.lineTo (x1, y1);
lines_mc.lineTo (x2, y2);
lines_mc.lineTo (x3, y3);
lines_mc.lineTo (x4, y4);
if (x1 != 200 && !firstStep) {
x1 == undefined ? x1=100 : x1 += 5;
y1 = 100;
}
if (x1 == 200 && !secondStep) {
firstStep = true;
x2 = x1;
y2 == undefined ? y2=100 : y2 += 5;
}
if (y2 == 200 && !thirdStep) {
secondStep = true;
x3 == undefined ? x3=y2 : x3 -= 5;
y3 = y2;
}
if (x3 == 100) {
thirdStep = true;
x4 = x3;
y4 == undefined ? y4=y2 : y4 -= 5;
}
};

etc
21.03.2007, 02:30
Потому что у тебя некоторые из x1, x2, x3, x4 равны undefined.

Mr. Fixit
21.03.2007, 02:51
я написал если undefined принимает значение.. пробовал все, кроме правильного подхода... где же он ау(000101100) =))

etc
21.03.2007, 03:01
_root.createEmptyMovieClip ('lines_mc', 0);
lines_mc.lineStyle (1);
onEnterFrame = function () {
//lines_mc.clear ();
trace([x1,x2,x3,x4]);
lines_mc.moveTo (100, 100);
lines_mc.lineTo (x1, y1);
lines_mc.lineTo (x2, y2);
lines_mc.lineTo (x3, y3);
lines_mc.lineTo (x4, y4);
if (x1 != 200 && !firstStep) {
x1 == undefined ? x1=100 : x1 += 5;
y1 = 100;
}
if (x1 == 200 && !secondStep) {
firstStep = true;
x2 = x1;
y2 == undefined ? y2=100 : y2 += 5;
}
if (y2 == 200 && !thirdStep) {
secondStep = true;
x3 == undefined ? x3=y2 : x3 -= 5;
y3 = y2;
}
if (x3 == 100) {
thirdStep = true;
x4 = x3;
y4 == undefined ? y4=y2 : y4 -= 5;
}
};
По-моему, очень показательно…

Mr. Fixit
21.03.2007, 03:28
и как выйти.. не подставить же x1..x4 & y1..y4 константу...

wvxvw
21.03.2007, 04:59
Сначала задавать переменные, а потом проводить с ними манипуляции. По-идее этот скрипт вобщем-то и компилироваться не должен, ну или с ошибкой...