Solved

JavaScript Animation

Posted on 1997-10-14
1
370 Views
Last Modified: 2013-11-19
Hi there Can anybody help me.I am trying to make an animation of 10 Gifs using JavaScript with the animation starting on mouseover and stopping when the mouse is off . I tried everything I know (which isn't much) but I could not make it work.Can anyone post a script that will do that. Thanks!!!
0
Comment
Question by:albion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
Holger101497 earned 100 total points
ID: 1271315
Hi albion!
Here's a script that'll do it:
I also uploaded it to http://home1.gte.net/stratmhx/Animation/anim.html, just in case you want to see it "in action". It'll work fine in Netscape.
You can initialize as many images as you want in the anim-Array and the code will automatically play all of them (using the length-Attribute). Pathnames can be relative or absolute, just as they would be in the document.

<HTML>
<HEAD>
<TITLE>Animation-Demo</TITLE>
<script language="JavaScript">
  anim=new Array();  // preload Images for smooth Animation
  anim[0]=new Image(); anim[0].src="1.jpg";
  anim[1]=new Image(); anim[1].src="2.jpg";
  anim[2]=new Image(); anim[2].src="3.jpg";
  anim[3]=new Image(); anim[3].src="4.jpg";
  anim[4]=new Image(); anim[4].src="5.jpg";
  apos=0; //next Image to be used for animation

  function Anim() {
    document.images[0].src=anim[apos++].src;
    apos%=anim.length; //wrap at end
    AnimTimer=setTimeout("Anim()",300);
  }
</script>

</HEAD>

<BODY bgcolor=red>
<H1>  Hi there!</H1>
<H2> This is a short demo of the animation you were looking for...
<!-- if the link is supposed to lead somewhere, just remove the "return false", which stops Netscape from following the link -->
  <a href="javascript:void()" onclick="return false" onMouseOver="Anim()" onMouseOut="clearTimeout(AnimTimer)">
  <!-- need a link for mouseover!! -->
  <!-- clearTimeout stops the animation -->
    <img src="1.jpg" height=40 width=40 border=0></a>
<BR>
<H3>
Good luck and have fun!
</H3>
</BODY>
</HTML>

online at http://home1.gte.net/stratmhx/Animation/anim.html (for a limited time, so don't count on it in December!)
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question