Flash animation in Javascript : Animation « GUI Components « JavaScript DHTML

Flash animation in Javascript

 <!-- ***********************************************************
Example 5-10
"Dynamic HTML:The Definitive Reference"
2nd Edition
by Danny Goodman
Published by O'Reilly & Associates  ISBN 0-596-00316-1
Copyright 2002 Danny Goodman.  All Rights Reserved.
************************************************************ -->
<title>Changing className Properties</title>
<style type="text/css">
    .red    {
              color: red;
              border: 2px solid red;

    .green  {
              color: green;
              border: 2px solid yellow;

    .yellow {
              color: yellow;
              border: 2px solid blue;

    .blue   {
              color: blue;
              border: 2px solid green;
<script language="JavaScript" type="text/javascript">
// Set global variables
var totalCycles = 0;
var currColor = 0;
var classes, intervalID;
// Build array of rule selector names
function init() {
    classes = ["red", "green", "yellow", "blue"];
// Advance the color by one
function cycleColors() {
    // reset counter to 0 if it reaches 3; otherwise increment by 1
    currColor = (currColor == 3) ? 0 : ++currColor;
    // set style color to new color from array
    document.getElementById("hot1").className = classes[currColor];
    // invoke this function again until total = 27 so it ends on red
    if (totalCycles++ < 27) {
        intervalID = setTimeout("cycleColors()", 100);
    } else {
<body onload="init(); cycleColors();">
<h1>Welcome to the <span class="red" id="hot1">Hot Zone</span> Web Site</h1>


Related examples in the same category

1.Attack animation
2.Circle Animation
3.Right to left animation
4.Flash animation in JavaScript: Changing style Properties
5.Animation along Straight Line
6.Animation along a Circle
7.Dancing Text (IE)
8.Type Writer effect (IE)
9.Type Writer Effect 1.1 (IE)
10.JavaScript Ticker 1.2 (IE)
11.Animation: Lottery Number Picker and Statistics
12.Animation: wriggly
13.Animation: welcome message
14.Animation: trio
15.Auto lotto dip
16.Animation: snow
17.Animation: star
18.Animation: mouse doodle
19.Animation: fireworks
20.Animation: pretty
21.Animation: Random Movement
22.Lotto number draw
23.Following eyes
24.Animation: three eyes
25.Animation: eyes
26.Spot light
27.Big static eyes
28.Animation based on DIV with color flash
29.Framework for creating CSS-based animations
30.Animate dynamic element h1 tag
31.Popup window animation (fly across screen)
32.Animation on several images
33.Using the onFilterChange Event Handler
34.JavaScript Animation
35.Periodically Updating the Text Displayed by an HTML Element
36.Moving an Airplane Across a Web Page
37.Link Hint Scroller 2.0 (IE)
38.Snow animation
39.Animation with JSTween