Results 1 to 3 of 3

Thread: FireWorks Script

  1. #1
    Join Date
    Dec 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default FireWorks Script

    Here's a really cool script that displays fireworks. (The script is within the source.) Unfortunately, the author did not allow for an easy and obvious way to set a time limit; they just keep going.

    I would like to place a counter within the script that shuts it off after a number of iterations.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The first thing you asked for was a timelimit. This can be achieved rather easily, like so:
    Code:
    window.setTimeout("myFW.stop()", 15000); // Turn off fireworks after 15 seconds
    To end after a certain number of fireworks, replace the existing JSFX.FireWorkDisplay.prototype.animate() function with the following:
    Code:
    var numFireworks = 0;
    JSFX.FireworkDisplay.prototype.animate = function()
    {
    if(numFireworks == 40) myFW.stop();
    else numFireworks++;
    status = this.loadCount;
    	if(this.loadCount < this.imgArray.length)
    		return;
    
    	for(var i=0 ; i<this.fireworks.length ; i++)
    		this.fireworks[i].animate();
    }
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Dec 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks. I did not know about the setTimeout function. And I really appreciate knowing which function in the fireworks script contains the loop that I was looking for.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •