ASNMTAP

 view release on metacpan or  search on metacpan

applications/htmlroot/JSFX_Fireworks.js  view on Meta::CPAN

}
JSFX.FireworkDisplay.animate = function()
{
	var i;
	for(i=0 ; i<JSFX.FireworkDisplay.Fireworks.length ; i++)
		JSFX.FireworkDisplay.Fireworks[i].animate();

	setTimeout("JSFX.FireworkDisplay.animate()", 30);
}
/*
 * End Class FireworkDisplay
 */

/*
 * Class Firework extends Layer
 */
JSFX.Firework = function(fwNo, theImages)
{
	var imgName = "fw"+fwNo;
	var htmlStr = "<IMG SRC='"+theImages[0].src+"' NAME='"+imgName+"'>"

	//Call the superclass constructor
	this.superC = JSFX.Layer;
	this.superC(htmlStr);

	this.frame		= 0;
	this.state		= "OFF";
	this.fwImages	= theImages;
	this.imgName	= imgName;
}
JSFX.Firework.prototype = new JSFX.Layer;

JSFX.Firework.prototype.animate = function()
{
	if(this.state == "ON")
	{
		this.frame++
		if(this.frame == this.fwImages.length)
		{
			this.frame = 0;
			this.state = "OFF";
			this.hide();
		}
		else
		{
			this.images[this.imgName].src = this.fwImages[this.frame].src;
		}
	}
	else if(this.state == "OFF")
	{
		if(Math.random() > 0.95)
		{
			var x=Math.floor(Math.random()*(JSFX.Browser.getMaxX()-100) );
			var y=Math.floor(Math.random()*(JSFX.Browser.getMaxY()-100) );
			this.moveTo(x,y);
			this.show();
			this.state="ON";
		}
	}
}
/*** If no other script has added it yet, add the ns resize fix ***/
if(navigator.appName.indexOf("Netscape") != -1 && !document.getElementById)
{
	if(!JSFX.ns_resize)
	{
		JSFX.ow = outerWidth;
		JSFX.oh = outerHeight;
		JSFX.ns_resize = function()
		{
			if(outerWidth != JSFX.ow || outerHeight != JSFX.oh )
				location.reload();
		}
	}
	window.onresize=JSFX.ns_resize;
}



( run in 1.830 second using v1.01-cache-2.11-cpan-d8267643d1d )