E' ovvio che lo stesso discorso vale per setIntervalOriginariamente inviato da MRj92
grazie mille per l'attenziona ma io non ho nessun timeout!![]()
Visto che non ho testato potrebbero anche esserci altri errori che non ho notato.codice:function EmarGallery(id,numStart) { var this_ = this; this.id = id; this.numStart = numStart; this.images = null; this.interval = null; this.OpacityIn = 0; this.IntervalIn = null; this.OpacityOut = 1; this.IntervalOut = null; this.current = null; this.prec = null; this.Load = function() { gallery = document.getElementById(this.id); if(gallery != null) { this.images = new Array(); var node = gallery.firstChild; while(node) { if (node.nodeType == 1) { this.images.push(node); } node = node.nextSibling; } alert("loaded!"); } }; this.ChangeImg = function(arg) { this.prec = this.current; if(arg > (this.images.length-1)) this.current = 0; else if(0 > arg) this.current = this.images.length-1; else this.current = arg; if(this.images[this.prec] != null) { //IntervalIn = setInterval('this_.FadeOut(this.images[this.prec])',1); this.images[this.prec].style.display = 'none'; this.setOpacity(this.images[this.prec],0); } this.images[this.current].style.display = 'block'; //this.images[this.current].style.left = Math.floor(Math.random()*300); this.IntervalIn = setInterval('this_.FadeIn(this.images[this.current])',1); }; this.ChangeRand = function() { var num; do{ num = Math.floor(Math.random()*images.length); }while(num == this.current || num == this.prec) this.ChangeImg(num); }; this.Play = function(sec,rand) { if(rand != true) { if(this.numStart != null) this.ChangeImg(this.numStart); else this.ChangeImg(0); if(this.images.length != 1) { this.interval = setInterval('this_.ChangeImg(this.current+1)',sec*1000); } } else{ if(this.numStart != null) this.ChangeImg(this.numStart); else this.ChangeRand(); if(this.images.length != 1) { this.interval = setInterval('this_.ChangeRand()',sec*1000); } } }; this.Stop = function() { clearInterval(this.interval); }; this.setOpacity = function(obj,value) { if(obj.style.filter != null) obj.style.filter = 'alpha(opacity=' + value*100 + ')'; else if(obj.filters != null) obj.filters.alpha.opacity = value*100; else obj.style.opacity = value; }; this.FadeIn = function(obj) { if(this.OpacityIn >= 1) { clearInterval(this.IntervalIn); this.IntervalIn = null; this.OpacityIn = 0; } else { this.OpacityIn = this.OpacityIn + 0.05; this.setOpacity(obj,this.OpacityIn); } }; this.FadeOut = function(obj) { if(this.OpacityOut <= 0) { clearInterval(this.IntervalOut); this.IntervalOut = null; this.OpacityOut = 1; } else { this.OpacityOut = this.OpacityOut - 0.05; this.setOpacity(obj,this.OpacityOut); } }; };

Rispondi quotando