Flash animation in JavaScript: Changing style Properties : Animation « GUI Components « JavaScript DHTML






Flash animation in JavaScript: Changing style Properties

 
 <!-- ***********************************************************
Example 5-9
"Dynamic HTML:The Definitive Reference"
2nd Edition
by Danny Goodman
Published by O'Reilly & Associates  ISBN 0-596-00316-1
http://www.oreilly.com
Copyright 2002 Danny Goodman.  All Rights Reserved.
************************************************************ -->
<html>    
<head>
<title>Changing style Properties</title>
<style type="text/css">
    #hot1 {color:red}
</style>
<script language="JavaScript" type="text/javascript">
// Set global variables
var totalCycles = 0;
var currColor = 0;
var colors, intervalID;
// Build array of color names
function init() {
    colors = ["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").style.color = colors[currColor];
    // invoke this function again until total = 27 so it ends on red
    if (totalCycles++ < 27) {
        intervalID = setTimeout("cycleColors()", 100);
    } else {
        clearTimeout(intervalID);
    }
}
</script>
</head>
<body onload="init(); cycleColors();">
<h1>Welcome to the <span id="hot1">Hot Zone</span> Web Site</h1>
<hr>
</body>
</html>


           
         
  








Related examples in the same category

1.Attack animation
2.Circle Animation
3.Right to left animation
4.Flash animation in Javascript
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