salve ragazzi!
Ho bisogno di voi perchè non mi capisco!
Ho creato la seguente classa javascript:
codice:
function EmarGallery(id,numStart)
{
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);
}
};
};
poi ho questo file:
codice:
var gallery = new EmarGallery("PortfolioGallery",0);
window.onload = function()
{
LoadMenu();
externalLinks();
gallery.Load();
gallery.Play(4,true);
}
window.onunload = function()
{
gallery.Stop();
}
dove mi da i seguenti errori:
- gallery.Play is not a function
- gallery.Stop is not a function
La cosa che mi fa incazzare è che non capisco perchè gallery.Load() funziona!