Solved

JavaScript Animation

Posted on 1997-10-14
1
346 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now