By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,598 Members | 1,897 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,598 IT Pros & Developers. It's quick & easy.

Animated images

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

"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.