Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

JavaScript Animation

Posted on 1997-10-14
1
Medium Priority
?
387 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 400 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

597 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