JavaScript Animation : JavaScript DHTML examples (example source code) » GUI Components » Animation

JavaScript DHTML
C++
Java Products
Java Articles
JavaScript DHTML Home  »   GUI Components   » [  Animation  ]   
 



JavaScript Animation

Please note that some example is only working under IE or Firefox.


/*
Mastering JavaScript, Premium Edition
by James Jaworski 

ISBN:078212819X
Publisher Sybex CopyRight 2001
*/
<HTML>
<HEAD>
<TITLE>Simple Animation</TITLE>
<SCRIPT LANGUAGE="JavaScript"><!--
function initialize() {
 start=false
 imageSource=new Array(5)
 for(var i=0;i<5;++i){
  imageSource[i]=new Image()
  imageSource[i].src="image"+i+".gif"
 }
 delay=500
 delta=100
 nextImage=1
 startAnimation()
}
function startAnimation() {
 interval=setInterval('animate()',delay)
}
function setStart() {
 start = true
}
function animate() {
 if(start==true){
  i=nextImage
  ++nextImage
  nextImage%=5
  if(imageSource[i].complete)
   document.display.src=imageSource[i].src
 }
}
function goFaster() {
 clearInterval(interval)
 delay-=delta
 if(delay<100delay=100
 startAnimation()
}
function goSlower() {
 clearInterval(interval)
 delay+=delta
 startAnimation()
}
// --></SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<SCRIPT LANGUAGE="JavaScript"><!--
initialize()
// --></SCRIPT>
<H1>Simple Animation</H1>
<IMG NAME="display" SRC="image0.gif" onLoad="setStart()">
<BR>
<FORM>
<INPUT TYPE="BUTTON" NAME="faster" VALUE="Faster" ONCLICK="goFaster()">
<INPUT TYPE="BUTTON" NAME="slower" VALUE="Slower" ONCLICK="goSlower()">
</FORM>
</BODY>
</HTML>
Related examples in the same category
1.  Circle Animation
2.  Right to left animation
3.  Flash animation in Javascript
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.  Periodically Updating the Text Displayed by an HTML Element
35.  Moving an Airplane Across a Web Page
36.  Link Hint Scroller 2.0 (IE)








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.