471,601 Members | 1,210 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,601 software developers and data experts.

Animated images

Can javascript build animated .gif or .jpeg ....I mean files *gif or
*.jpeg that show animated images when are opened ( or is it another
language that do it ? ) ?
Thanks a lot.
Aug 31 '06 #1
4 2324
Lando wrote:
Can javascript build animated .gif or .jpeg ....I mean files *gif or
*.jpeg that show animated images when are opened ( or is it another
language that do it ? ) ?
Thanks a lot.
Javascript can set an <IMGelement's src property to an image url. If
the image is an animated GIF, then it will be animated by the browser.
If you whish to build custom animation with a collection of images, you
have to use a time that will change the src property value of the
element to the next image in line. Something like :

var _imageId = "someImageElementId";
var _imageQueue = new Array();
var _index = 0;

// 1) load image queue with url as _imageQueue[n] = "url";

function setNextImageIndex() {
var image = document.getElementById( _imageId );
if ( image ) {
_index++;
if ( index >= _imageQueue.length ) index = 0;

image.src = _imageQueue[_index];
}
}

setInterval( setNextImageIndex, 200 ); // change image 5x per seconds

--------------------

The images should be of the same size... but they can be of different
formats (all must be supported by the browser !). The browser is
supposed to use the cached version of the images, but if you whish, you
can preload the images first... but I'll let you search for more
invormations about this on your own (Google is your friend.)

Hope this helps.

Aug 31 '06 #2
Lando said the following on 8/31/2006 8:08 AM:
Can javascript build animated .gif or .jpeg ....
No.
I mean files *gif or *.jpeg that show animated images
when are opened
..jpeg can be animated?
( or is it another language that do it ? ) ?
Not another language, a type of program. You want an image manipulation
program such as PSP or any other one that is capable of producing
animated images.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 31 '06 #3
You can simulate animated graphics using only javascript as noted in
the first reply (by using a timer and changing the src attribute of the
image DOM element.

But, you can actually create an animated GIF file using a piece of
freeware called GIFAnimator
(http://www.versiontracker.com/dyn/moreinfo/win/13212). There also use
to be the GIF Constructor Set, but I don't know where it went.

There are many more GIF animation utilities for a small fee out there.
Just Google it.

Aug 31 '06 #4

"Tom Cole" <tc****@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
You can simulate animated graphics using only javascript as noted in
the first reply (by using a timer and changing the src attribute of the
image DOM element.

But, you can actually create an animated GIF file using a piece of
freeware called GIFAnimator
(http://www.versiontracker.com/dyn/moreinfo/win/13212). There also use
to be the GIF Constructor Set, but I don't know where it went.

There are many more GIF animation utilities for a small fee out there.
Just Google it.
Or go funky with css and clip... like so:
http://www.braincast.nl/oi/oi8/
Aug 31 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Salmo Bytes | last post: by
2 posts views Thread by Malcolm | last post: by
4 posts views Thread by Al_C | last post: by
7 posts views Thread by Gary Kaucher | last post: by
4 posts views Thread by Jeff | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.