Просмотр полной версии : цикл
julia_leo
11.08.2007, 17:22
Ребята, подскажите, ламеру. :mad:
Надо циклически просматривать фотки. Без цикла все работает. В цикле программа зависает.
Подскажите что не так.
var j = 0;
this.createEmptyMovieClip("holder_mc", 1);
holder_mc.loadMovie("im1.swf");
function callback()
{
_root.holder_mc._alpha -=1;
if(_root.holder_mc._alpha <=0) { j++; _root.holder_mc._alpha = 100; trace("j="+j); clearInterval(time); }
}
while(j<=1)
{
time = setInterval(callback, 1 );
}
Ага. И когда, по-твоему, твой вайл прекратится? Точно - НИКОГДА.
Когда выполняется цикл, все почтительно курят в сторонке,и никакая j у тебя не изменится.
зачем тебе сдесь нужен цикл??? Код, который написан в цикле, будет выполняться до тех пор, пока услове истинно. Т.е. условия в стиле j<=1, без счетчика в нутри цикла j++ или что то типа того, тут не уместны. У тебя получается что твой код должен выполниться бесконечное количество раз, поэтому и виснет.
Зачем setInterval писать в цикле?
2 udaaff - это попытка сделать бесконечный переключатель - цикл запускается, альфа падает - упала - цикл обрывается и запускается снова.
Просто счетчик j, поставленный вне тела цикла, само собой, не работает
----------------
UPD на самом деле фиг знает, для чего всё это. Не пойму логику :) Запускающиеся пачкой интервалы - может это вирус?
var theEarthIsTurning:Boolean = true;
var Things:Array = new Array("Wheeeeee","I can fly","I do believe in faries","It ain't gonna stop spinning","Stop? - not gonna happen","Turny turny turny turny","Teee-heee","I know you're loving it");
while(theEarthIsTurning){
trace("[Please mind the gap] "+Things[(Things.length-1)*Math.random()]+"!");
}
_root.redButton.on(press){
tryToStopTheEarth();
}
tryToStopTheEarth = new function():void{
trace("Tonight Im gonna have myself a real good time
I feel alive and the world turning inside out yeah!
And floating around in ecstasy
So dont stop me now dont stop me
cause Im having a good time having a good time
Im a shooting star leaping through the sky
Like a tiger defying the laws of gravity
Im a racing car passing by like lady godiva
Im gonna go go go
Theres no stopping me
Im burning through the sky yeah!
Two hundred degrees
Thats why they call me mister fahrenheit
Im travling at the speed of light
I wanna make a supersonic man out of you
Dont stop me now Im having such a good time
Im having a ball dont stop me now
If you wanna have a good time just give me a call
Dont stop me now (cause Im havin a good time)
Dont stop me now (yes Im havin a good time)
I dont want to stop at all
Im a rocket ship on my way to mars
On a collision course
I am a satellite Im out of control
I am a sex machine ready to reload
Like an atom bomb about to
Oh oh oh oh oh explode
Im burning through the sky yeah!
Two hundred degrees
Thats why they call me mister fahrenheit
Im travling at the speed of light
I wanna make a supersonic woman of you
Dont stop me dont stop me
Dont stop me hey hey hey!
Dont stop me dont stop me ooh ooh ooh (I like it)
Dont stop me dont stop me
Have a good time good time
Dont stop me dont stop me ah
Im burning through the sky yeah!
Two hundred degrees
Thats why they call me mister fahrenheit
Im travling at the speed of light
I wanna make a supersonic man out of you
Dont stop me now Im having such a good time
Im having a ball dont stop me now
If you wanna have a good time just give me a call
Dont stop me now (cause Im havin a good time)
Dont stop me now (yes Im havin a good time)
I dont want to stop at all");
}
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.