Показать сообщение отдельно
  #4 (permalink)  
Старый 25.05.2011, 13:47
Профессор
Посмотреть профиль Найти все сообщения от Solovei95
 
Регистрация: 15.03.2011
Сообщений: 353

window.addEventListener("load",function(){
var count = document.getElementsByClassName("screen").length;
var canv = [];
var cl = [];
var time = [];
var d = [];
var img = [];
var tim = [];
var bld = [];
var c = [];
var n = [];
var fram = [];
var image = [];
var ctx = [];

for(i=0;i<count;i++){
canv[i] = document.getElementsByClassName("screen")[i];
ctx[i] =  canv[i].getContext("2d");
cl[i] = canv[i].getAttribute("data-classes");
time[i] = parseInt(canv[i].getAttribute("data-time"));
d[i] = 0;

window.addEventListener("load",function(i){
c[i] = document.getElementsByClassName(cl[i]).length;
img[i] = [];
tim[i] = [];
bld[i] = [];
fram[i] = [];
image[i] = [];

for(n[i]=0;n[i]<c[i];n[i]++){

fram[i][n[i]] = document.getElementsByClassName(cl[i])[n[i]];
img[i][n[i]] = fram[i][n[i]].getAttribute("src");
tim[i][n[i]] = parseInt(fram[i][n[i]].getAttribute("data-time"));
bld[i][n[i]] = fram[i][n[i]].getAttribute("data-blend");
fram[i][n[i]].style["display"] = "none";

image[i][n[i]] = new Image();
image[i][n[i]].src = img[i][n[i]];

if(isNaN(tim[i][n[i]])==true)
{tim[i][n[i]]=time[i]}

if(bld[i][n[i]]=="true"){bld[i][n[i]]=true} else
if(bld[i][n[i]]=="false"){bld[i][n[i]]=false} else
{bld[i][n[i]]=false}

}


window.addEventListener("load",draw(i),false);
function draw(){

d[i]++;
if(d[i]>=c[i])
{d[i]=0
ctx[i].clearRect(0,0,canv[i].width,canv[i].height);
}

if(bld[i][d[i]]==false){
ctx[i].clearRect(0,0,canv[i].width,canv[i].height);
}
ctx[i].drawImage(image[i][d[i]],0,0);

setTimeout(draw,tim[i][d[i]]);
}

}(i),false);
}

},false);


Мне нужно установить автообновление каждые 1 секунду в райне
for(n[i]=0;n[i]<c[i];n[i]++){

fram[i][n[i]] = document.getElementsByClassName(cl[i])[n[i]];
img[i][n[i]] = fram[i][n[i]].getAttribute("src");
tim[i][n[i]] = parseInt(fram[i][n[i]].getAttribute("data-time"));
bld[i][n[i]] = fram[i][n[i]].getAttribute("data-blend");
fram[i][n[i]].style["display"] = "none";

image[i][n[i]] = new Image();
image[i][n[i]].src = img[i][n[i]];

if(isNaN(tim[i][n[i]])==true)
{tim[i][n[i]]=time[i]}

if(bld[i][n[i]]=="true"){bld[i][n[i]]=true} else
if(bld[i][n[i]]=="false"){bld[i][n[i]]=false} else
{bld[i][n[i]]=false}

}
Ответить с цитированием