<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Piterwilson = Juan Carlos Ospina Gonzalez &#187; javascript</title>
	<atom:link href="http://www.piterwilson.com/personal/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.piterwilson.com/personal</link>
	<description>Piterwilson is/es Juan Carlos Ospina Gonzalez</description>
	<lastBuildDate>Sat, 17 Sep 2011 16:08:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Iphone friendly alternative to the animated gif (with Javascript and prototype js)</title>
		<link>http://www.piterwilson.com/personal/2009/03/01/iphone-friendly-alternative-to-the-animated-gif-with-javascript-and-prototype-js/</link>
		<comments>http://www.piterwilson.com/personal/2009/03/01/iphone-friendly-alternative-to-the-animated-gif-with-javascript-and-prototype-js/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 19:48:27 +0000</pubDate>
		<dc:creator>Piterwilson</dc:creator>
				<category><![CDATA[code example / ejemplos de codigo]]></category>
		<category><![CDATA[web cam stop motion]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.piterwilson.com/personal/?p=143</guid>
		<description><![CDATA[UPDATE: This class has been updated, please see more details here. The problem: Mobile Safari only allows animated GIFs up to a certain size (that is a function of the dimensions and number of frames).  If the images are larger than the limit, Safari only renders the first frame. Much to my misfortune while working [...]]]></description>
			<content:encoded><![CDATA[<p><script src="http://www.piterwilson.com/stuff/js/prototype.js"></script><br />
<script src="http://www.piterwilson.com/stuff/js/animationPlayer.js"></script>UPDATE: This class has been updated, <a href="http://www.piterwilson.com/personal/2009/03/23/animationplayer-js-class-updated/">please see more details here</a>.</p>
<p><strong>The problem:</strong></p>
<blockquote><p>Mobile Safari only allows animated GIFs up to a certain size (that is a function of the dimensions and number of frames).  If the images are larger than the limit, Safari only renders the first frame.</p></blockquote>
<p>Much to my misfortune while working with a friend to make an Iphone app for the <a href="http://www.piterwilson-toys.com/wcsmt2/">WCSMT website</a>, we came to the realization that the Iphone has serious limitations to display animated gifs. Coupled with the total inability (or better put : reluctance) to display flash content, it makes the Iphone very unfriendly to displaying short animation formats, like the ones on <a href="http://www.piterwilson-toys.com/wcsmt2/">WCSMT </a> or <a href="http://www.miniclip.com/sketch-star/en/player.php?id=2565885">Miniclip&#8217;s SketchStar</a>.</p>
<p>I realize this is a very small section of the market (people who like short animated gifs) and that the animated gif is an ancient format to begin with and not a lot of people have a practical use for it. Still i set out to find the way to display short-lenght animation formats where proper video pulig-ins are overkill (or too difficult to implement practically with web-based toys that create animations).</p>
<p><strong>Solution:</strong></p>
<p>A javascript class that will take an array of images and display it at a constant speed. This is pretty much a simplified javascript slideshow that goes very fast!</p>
<p>Here&#8217;s an example, making an animated gif of this to display on the Iphone would be impossible:</p>
<div id="animationPlayer" style="width:320px;height:300px;">
</div>
<p><script>
var frames = new Array();
var i;
for(i=1;i<10;i++){
frames.push("http://www.piterwilson.com/stuff/animation/animation000"+i+".jpg");
}
var myPlayer = new AnimationPlayer(frames,$('animationPlayer'));
myPlayer.play();
</script></p>
<p><strong>How does it work?</strong></p>
<p><code>&lt;script src=&quot;<a href="http://www.piterwilson.com/stuff/js/prototype.js&quot;&gt;&lt;/script&gt;" rel="nofollow">http://www.piterwilson.com/stuff/js/prototype.js&quot;&gt;&lt;/script&gt;</a><br />
&lt;script src=&quot;<a href="http://www.piterwilson.com/stuff/js/animationPlayer.js&quot;&gt;&lt;/script&gt;" rel="nofollow">http://www.piterwilson.com/stuff/js/animationPlayer.js&quot;&gt;&lt;/script&gt;</a><br />
&lt;div id=&quot;animationPlayer&quot; style=&quot;width:320px;height:240px&quot;&gt;<br />
&lt;/div&gt;<br />
&lt;script&gt;<br />
var frames = new Array();<br />
var i;<br />
for(i=1;i&lt;10;i++){<br />
frames.push(&quot;<a href="http://www.piterwilson.com/stuff/animation/animation000&quot;+i+&quot;.jpg&#038;quot" rel="nofollow">http://www.piterwilson.com/stuff/animation/animation000&quot;+i+&quot;.jpg&#038;quot</a>;);<br />
}<br />
var myPlayer = new AnimationPlayer(frames,$(&#039;animationPlayer&#039;));<br />
myPlayer.play();<br />
&lt;/script&gt;</code></p>
<p>1. Include prototype.js<br />
2. Include animationPlayer.js<br />
3. Declare and array of paths to the frames of the animation. They can be jpg, gif, png or whatever.<br />
4. Create an instance of the AnimationPlayer class, pass the array as parameter 1 and a div reference as parameter 2.<br />
5. Call the play() function! that's it!</p>
<p>You can also change the frame rate by setting AnimationPlayer.frameRate to any value (in milliseconds)</p>
<p>Get prototype JS at <a href="http://www.prototypejs.org/">http://www.prototypejs.org/</a><br />
Get the AnimationPlayer class here <a href="http://www.piterwilson.com/stuff/js/animationPlayer.js">http://www.piterwilson.com/stuff/js/animationPlayer.js</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.piterwilson.com/personal/2009/03/01/iphone-friendly-alternative-to-the-animated-gif-with-javascript-and-prototype-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

