<?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>Marcelo Duende</title>
	<atom:link href="http://www.marceloduende.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.marceloduende.com/blog</link>
	<description>something about html, javascript, actionscript and android</description>
	<lastBuildDate>Wed, 15 Feb 2012 01:13:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Playing multiple videos &#8211; html5/js</title>
		<link>http://www.marceloduende.com/blog/?p=28&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=playing-multiple-videos-html5js</link>
		<comments>http://www.marceloduende.com/blog/?p=28#comments</comments>
		<pubDate>Tue, 14 Feb 2012 19:58:38 +0000</pubDate>
		<dc:creator>Marcelo Duende</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.marceloduende.com/blog/?p=28</guid>
		<description><![CDATA[Heyo! Straight to the point, I just want to show you how to play an html5 video. First of all, there are some tools which will make this tutorial easier. I am using the http://videojs.com/ . This library allow to &#8230; <a href="http://www.marceloduende.com/blog/?p=28">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Heyo!</p>
<p>Straight to the point, I just want to show you how to play an html5 video.</p>
<p>First of all, there are some tools which will make this tutorial easier. I am using the <a href="http://videojs.com/" title="http://videojs.com/" target="_blank">http://videojs.com/</a> . This library allow to load and play very well videos with html5, but as always our friend html5 is nothing without it&#8217;s best friend javascript. I will show you some tricks I have learned these last days to make it play properly and also play multiple videos at the same video player.</p>
<h1>Playing the video</h1>
<p>First of all, download the tool or just use the absolute path to the live code, if you have internet connection. I am using the absoute path as below within my head tag.</p>
<pre name="code" class="html">
<link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/c/video.js"></script>
</pre>
<p>Once you have it done, just add a div into the body, and inside of the div add another tag, called video as showed below. </p>
<pre name="code" class="html">
<div>
	<video>
	</video>
</div>
</pre>
<p>Alright, pretty good, now you have to add some attributes to this tag to make it happen.</p>
<pre name="code" class="html">
<video id="my_video_1" class="video-js vjs-default-skin" controls
preload="auto" width="640" height="264" poster="images/poster.jpg"
data-setup="{}"></video>
</pre>
<p>Now, you should be asking yourself, what the hell is this? Alright, not a big deal, really. I&#8217;ll explain attribute by attribute.</p>
<p><strong>id</strong> = the ID name to the video.<br />
<strong>class</strong> = the style for the video player skin, it is customizable, you have to have the .js.css file in your computer to change it.<br />
<strong>controls</strong> = are the controls for your skin.<br />
<strong>preload</strong> = you know what is a preload, right?<br />
<strong>width/height</strong> = you know as well.<br />
<strong>poster</strong> &#8211; it is the image that will show up before play the video.<br />
<strong>data-setup</strong> = you can use the data-setup attribute to provide options in the JSON format. This is also how you would set options that aren&#8217;t standard to the video tag.</p>
<p>Okay, almost done with the video tag, there is only one more thing to be done, the video sources. That is where it gets more tricky.</p>
<p>You should use three different video formats to play on all browsers. They are webm, ogv and mp4. There are a lot of conversors out there, choose yours. So then, the final video tag code is&#8230;</p>
<pre name="code" class="html">
<div>
	<video id="my_video_1" class="video-js vjs-default-skin" controls
	preload="auto" width="640" height="264" poster="images/poster.jpg"
	data-setup="{}">
		<source src="video/test.webm" type='video/webm'>
		<source src="video/test.ogv" type='video/ogg; codecs="theora, vorbis"' >
		<source src="video/test.mp4" type='video/mp4'>
	</video>
</div>
</pre>
<p>Okay, send it to your server, you should have it working when hit the play button. BUT, for couple servers we will figure problems in Firefox. Why? We have to change the .htaccess file. DON&#8217;T FREAK OUT, it is the easiest part of this tutorial, really. Just create a plain txt or rtf file and add what is below.</p>
<p># Video<br />
AddType video/ogg ogv<br />
AddType video/mp4 mp4 m4v<br />
AddType video/webm webm</p>
<p>Save it locally and then, upload to your server (same folder which the video.html was uploaded), once it is uploaded, rename the file to &#8220;.htaccess&#8221;, it gets hidden in some ftp clients, I&#8217;d advice to use the cyberduck, where you can see hidden files.</p>
<p>Ok, access your html and play it, it should play at any browser.</p>
<h1>Playing multiple videos</h1>
<p>This second part I&#8217;ll use Javascript to change the src and add another videos to the player.</p>
<p>Create a javascript file called videoHandler.js and save within your project. Here we gonna put the code to handle this video tag.</p>
<p>First of all, let&#8217;s create the variable that will get the element by ID.</p>
<pre name="code" class="javascript">
var myVideo = _V_("my_video_1"); // get my <video> tag element.
</pre>
<p>Now we create the listener to know when the video is complete and the call for the new video.</p>
<pre name="code" class="javascript">
var myVideo = _V_("my_video_1"); // get my videojs.
function onComplete(){
	var myVideo1 = document.getElementsByTagName('video')[0]; // get my <video> tag.
	var videoPlaying = myVideo1.currentSrc; // get the file being played
	var ext = videoPlaying.substr(videoPlaying.lastIndexOf(".")); // figure the correct extension
	myVideo1.src = 'video/eu'+ext; // set up the new src
	myVideo.load(); // load the new video
	myVideo.play(); // play the new video
	myVideo.removeEvent("ended", onComplete); // remove the listener
};
myVideo.addEvent("ended", onComplete); // listener handler
</pre>
<p>Make sure the javascript file was added to the html file at the very bottom, before the body tag has been closed.</p>
<pre name="code" class="html">
<script src="js/videoHandlers.js"></script>
</pre>
<p>You can find more info about the videojs at their website <a href="http://videojs.com/docs/api/" title="VideosJS" target="_blank">VideoJS</a></p>
<p><strong>Browsers tested: </strong></p>
<p>Windows: IE9, IE8, Chrome, Firefox<br />
Mac: Chrome, Firefox, Safari<br />
Android: Firefox</p>
<p><strong>Final Example:</strong></p>
<p><a href="http://www.marceloduende.com/html5Video" title="HTML5 VIDEO" target="_blank">HTML5 VIDEO</a></p>
<p><strong>Final Files:</strong></p>
<p><a href="https://github.com/marceloduende/MultipleVideoPlayer" title="Git Hub">Final fles at github</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marceloduende.com/blog/?feed=rss2&#038;p=28</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Event Listeners</title>
		<link>http://www.marceloduende.com/blog/?p=25&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javascript-event-handlers</link>
		<comments>http://www.marceloduende.com/blog/?p=25#comments</comments>
		<pubDate>Sun, 22 Jan 2012 04:51:09 +0000</pubDate>
		<dc:creator>Marcelo Duende</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.marceloduende.com/blog/?p=25</guid>
		<description><![CDATA[Hey guys, You may be thinking, why I am talking about javascript. Well, to be honest, I have started my life as a developer with javascript. After having a little conversation with my friend Jay Moretti couple months ago, about &#8230; <a href="http://www.marceloduende.com/blog/?p=25">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hey guys,</p>
<p>You may be thinking, why I am talking about javascript. Well, to be honest, I have started my life as a developer with javascript. After having a little conversation with my friend <a href="http://www.jaymoretti.com/" title="Jay Moretti" target="_blank">Jay Moretti</a> couple months ago, about html5, he cleared my mind about what was html5. He wisely said &#8220;Marcelo, html5 is javascript!&#8221;. Coming from this point, I would say that I can be classified as html developer. Just kidding <img src='http://www.marceloduende.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h1>Back in time</h1>
<p>Five or six years ago I used to set up my event listeners as anonymous functions, as below.</p>
<pre name="code" class="javascript">
myElement.onclick = function() {
	//my click handler
};
</pre>
<p>Note at the code above, that I have a specific function only for that element, which makes me write too much code and not reusing it in the future.</p>
<pre name="code" class="javascript">
myElement.onclick = myFunction;
function myFunction(){
	//my click handler
}
</pre>
<p>At this example we can reuse the code into the method, but it&#8217;s pretty sketchy, isn&#8217;t it?</p>
<p>Okay, let&#8217;s go by the beginning, if you look at the first block of code, I&#8217;m using a semicolon after the curly braces. At the second block of code, I am not. Why?<br />
At the first block, there was no function call, it was a statement where I&#8217;m just saying that the myElement.onclick assigns a function. So, without the semicolon it doesn&#8217;t work in some cases.</p>
<p>Nowadays, javascript has another and better way to create event listeners.</p>
<pre name="code" class="javascript">
//adding event listener
myElement.addEventListener('click', methodName, false);
function methodName(){
	//my click handler
}

//removing event listener
myElement.removeEventListener('click', methodName, false);
</pre>
<p>Here, I have an organized way, but not safe yet, to create my event listeners. I can reuse the methodName() function in the future, which saves me time of development.<br />
You may be asking yourself, -Why isn&#8217;t it safe to use?; Simple, our cool friend, internet explorer 8 and older versions don&#8217;t understand the addEventListener method.</p>
<p>OMG, Internet Explorer again cracking the web. Calm down, we have three solutions for this cross-browser issue. I&#8217;ll explain one by one.</p>
<h1>Please, save the web</h1>
<p>The internet has generated a lot of headaches for developers, most part of that is because of the Internet Explorer, the browser that doesn&#8217;t evolve as much as Chrome and Firefox.</p>
<p>To avoid problems with event handlers on IE, we have three ways to go:</p>
<p>First:<br />
The simple and weak way. </p>
<pre name="code" class="javascript">
//Internet Explorer 8 and previous versions
myElement.attachEvent('onclick', methodName);
</pre>
<p>On this way I just set up this other method called attachEvent(); which can be understood by IE8 and previous.</p>
<p>Second:<br />
To create a cross-browse event listener identifier, hummm, looks fun!</p>
<pre name="code" class="javascript">
function addCrossBrowseEventListener(myElement, myEvent, myFunction) {
	if(myElement.addEventListener){
		myElement.addEventListener(myEvent, myFunction, false);
		return true;
	} else {
		myElement.attachEvent('on'+myEvent, myFunction);
		return true;
}
</pre>
<p>This bad boy up there should help you with major cross-browse issues, it checks if the addEventListener function exists, if yes, use it, otherwise use attachEvent.</p>
<p>Looks awesome, but, we have a safer and better way to fix the cross-browse issues for these event listeners, the famous jQuery or another JS library.<br />
<a href="http://jquery.com/" title="Download the jQuery from here" target="_blank">Download the jQuery from here</a></p>
<p>jQuery takes care of the whole cross-browse issues that could happen and it&#8217;s always up to date. To set your listener up with jQuery is pretty simple and useful.</p>
<pre name="code" class="javascript">
//adding event listener
$(myElement).live('click', methodName);
function methodName(){
	//do something
}

//removing event listener
$(myElement).die('click', methodName);
</pre>
<p>Thanks to <a href="http://www.igorcosta.com/blog/" title="Igor Costa" target="_blank">Igor Costa</a> for the jQuery help. Very appreciated, man.</p>
<p>For a complete list of events, <a href="http://api.jquery.com/category/events/" title="check this out" target="_blank">check this out</a></p>
<h1>Conclusion</h1>
<p>There is still hope at the internet, I know javascript is not even close to a strong typed language, but we can do it better using the obvious and right methods.</p>
<p>I hope you guys have enjoyed, from now on I&#8217;ll be posting more about javascript and html5. Stay tunned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marceloduende.com/blog/?feed=rss2&#038;p=25</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Brazilian vacations!</title>
		<link>http://www.marceloduende.com/blog/?p=22&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=brazilian-vacations</link>
		<comments>http://www.marceloduende.com/blog/?p=22#comments</comments>
		<pubDate>Wed, 04 Jan 2012 14:32:22 +0000</pubDate>
		<dc:creator>Marcelo Duende</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.marceloduende.com/blog/?p=22</guid>
		<description><![CDATA[Hey my dear readers, hope it finds all you well in this new year! Happy 2012! I&#8217;ll tell you about my vacations in Brazil. After two years living in USA, I&#8217;ve faced a lot of contrast and I&#8217;ll share these &#8230; <a href="http://www.marceloduende.com/blog/?p=22">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hey my dear readers, hope it finds all you well in this new year! Happy 2012!</p>
<p>I&#8217;ll tell you about my vacations in Brazil. After two years living in USA, I&#8217;ve faced a lot of contrast and I&#8217;ll share these stories with you.</p>
<h1>São Paulo</h1>
<p>First thing I&#8217;ve faced in Brazil was in São Paulo. The airport officials were on strike! Welcome back Marcelo. I spent, literally, 3 hours at the airport to pass through the immigration. We are about to have Olympic Games and World Cup in Brazil&#8230; how?</p>
<p>São Paulo was always an ugly city, the thing that makes São Paulo a good place are the people. I had the pleasure to meet Danilo Rodrigues which was my coworker in NYC and Rafael Rinaldi, both great friends that I care a lot. That was the best part of São Paulo, all the rest was shit to me (visa, document problems, noise, stress and money spent).</p>
<p>Ok, I went to the american consulate and guess what, couldn&#8217;t renew my visa, why? I didn&#8217;t make the proper appointment! I had to spend R$ 300 (around U$ 200), at the clandestine trade to get another appointment as soon as possible, once my life is in Los Angeles. Another great memory of São Paulo. #NOT</p>
<p>Note: I spent around R$ 1000 (U$ 800) with taxes in Brazil at this trip!</p>
<h1>Passo Fundo</h1>
<p>Finally I flew to my hometown, I don&#8217;t know what I was expecting, maybe I thought I was Frodo and I was going back to the shire! No, Passo Fundo, my hometown has increased the crime average, it was really dangerous to walk on the streets with different clothes, they could steal it from you or worst.</p>
<p>Overall, I met my family which, with no doubt, was the best fact of my trip!</p>
<p>After a kind time spent with my family and friends, I flew back to São Paulo, in a madness to try to get my visa approved. At this time, São Paulo was good to me, I have gotten the visa in record time, 1.5 hours! Now I have to wait until my visa arrive!</p>
<h1>Curitiba</h1>
<p>Time to go to the city that made my education as man, rainy Curitiba. I really love this place and after living in São Paulo, Rio de Janeiro and know all the south main cities, I could easily say that Curitiba is the best city I ever lived in Brazil. Also is where I found the girl that will spend her life at my side <img src='http://www.marceloduende.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Though I was working remotely during the day, I had amazing dinners and happy hours with friends and my girlfriend&#8217;s family.</p>
<h1>Michel Teló</h1>
<p>Michel Teló isn&#8217;t a city or something that I like, he is a singer, a person that has my respect for being recognized in all country. How? I don&#8217;t know, I really don&#8217;t know, but it should be something that brazilians should ban FOREVER! Non sense lyric ever made. It doesn&#8217;t match our culture not even a bit. I really want to land in Brazil in December and not listening this song  anymore.</p>
<h1>Conclusion</h1>
<p>It is clearly proved that Brazil doesn&#8217;t have structure to have a world recognize event yet. It needs couple years to improve and change some stereotype that people judge each other. </p>
<p>Brazil is a great place, though. It just need more love from the politicians. I won&#8217;t make a list with all the items we should change as brazilians, we know what has to be done, and I&#8217;m not a good example as well, once I live outside of the country!</p>
<p>Now I&#8217;m getting ready to flight back to Los Angeles, I want to see how my house is going, I really miss my life right now!</p>
<p>Basically it was the resume of my trip to Brazil, I know it is nothing about technology, but it&#8217;s good to share sometimes.</p>
<p>Have a great 2012, everyone!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marceloduende.com/blog/?feed=rss2&#038;p=22</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jzoo &#8211; Graphics</title>
		<link>http://www.marceloduende.com/blog/?p=19&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jzoo-graphics</link>
		<comments>http://www.marceloduende.com/blog/?p=19#comments</comments>
		<pubDate>Wed, 17 Aug 2011 15:51:33 +0000</pubDate>
		<dc:creator>Marcelo Duende</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.marceloduende.com/blog/?p=19</guid>
		<description><![CDATA[Couple days ago, I have started my Java toolkit, which is kinda useful in some occasions (static shapes, dynamic resizable shapes). First of all, clone the project from GitHub. https://github.com/marceloduende/JZoo Use your desired software to do the work. I have &#8230; <a href="http://www.marceloduende.com/blog/?p=19">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Couple days ago, I have started my Java toolkit, which is kinda useful in some occasions (static shapes, dynamic resizable shapes).</p>
<p>First of all, clone the project from GitHub.</p>
<p><a href="https://github.com/marceloduende/JZoo" target="_blank">https://github.com/marceloduende/JZoo</a></p>
<p>Use your desired software to do the work. I have used GitHub for Mac, which is simply amazing.</p>
<p>All right, once you have it cloned in your computer, you can set up your project and add the src folder as path. If you already have it, grab the &#8220;com&#8221; folder and throw inside your path folder.</p>
<p>I&#8217;ll start with a regular Rectangle without special settings.</p>
<h2>Drawing Rectangle and Oval shapes</h2>
<pre name="code" class="java">View linearLayout = findViewById(R.id.YOUR_LAYOUT_ID); // add the layout ID right here
ShapeFactoryParameters b = new ShapeFactoryParameters().x(50).y(50).w(300).h(100).color(0xffffffff).kind("RECT"); // explanation below
ShapeFactory sf = new ShapeFactory(YOUR_ACTIVITY, b); // add the Activity
((LinearLayout) linearLayout).addView(sf); // adding view</pre>
<p>Explaining the second line.</p>
<p>What ShapeFactoryParameters does is to save all parameters and send it to the ShapeFactory.<br />
You can use like above or like below.</p>
<pre name="code" class="java">ShapeFactoryParameters b = new ShapeFactoryParameters();
b.x(50);
b.y(50);
b.w(300);
b.h(100);
b.color(0xffffffff);
b.kind("RECT");</pre>
<p><strong>NOTE:</strong> You have to use it before setting the parameters to the ShapeFactory;</p>
<p>The result for this would be something like this:</p>
<p><img src="http://www.marceloduende.com/blog/images/SC20110817-102643.png" alt="rect" /></p>
<p>To use and Oval Shape is exactly the same thing. Just change the kind(&#8220;RECT&#8221;); to kind(&#8220;OVAL&#8221;);</p>
<p><img src="http://www.marceloduende.com/blog/images/SC20110817-102944.png" alt="rect" /></p>
<h2>Drawing Stroke</h2>
<p>You can, also, easily add a stroke in your shapes, adding only two parameters.</p>
<pre name="code" class="java">ShapeFactoryParameters b = new ShapeFactoryParameters();
b.x(50);
b.y(50);
b.w(300);
b.h(100);
b.color(0xffffffff);
b.kind("RECT_STROKE"); // changed the kind
b.stroke(5); // added the stroke size</pre>
<p>And you can see something like this:</p>
<p><img src="http://www.marceloduende.com/blog/images/SC20110817-103115.png" alt="rect" /></p>
<h2>Drawing Round Shapes</h2>
<p>Another cool stuff is to add round shapes to your project. The round shape works different, you have to add a float value to determine the corners values. For this occasion I&#8217;ll use 20 pixels for all the corners.</p>
<pre name="code" class="java">
float[] corner = new float[] {20, 20, 20, 20, 20, 20, 20, 20 }; // change it for a different corner;
ShapeFactoryParameters b = new ShapeFactoryParameters();
b.x(50);
b.y(50);
b.w(300);
b.h(100);
b.color(0xffffffff);
b.kind("ROUND");
b.corner(corner);</pre>
<p>And you&#8217;ll have something like below:</p>
<p><img src="http://www.marceloduende.com/blog/images/SC20110817-103254.png" alt="rect" /></p>
<h2>Drawing Round Strokes</h2>
<pre name="code" class="java">
float[] corner = new float[] {20, 20, 20, 20, 20, 20, 20, 20 }; // change it for a different corner;
ShapeFactoryParameters b = new ShapeFactoryParameters();
b.x(50);
b.y(50);
b.w(300);
b.h(100);
b.color(0xffffffff);
b.kind("ROUND_STROKE");
b.corner(corner);
b.stroke(5);
</pre>
<p><img src="http://www.marceloduende.com/blog/images/SC20110817-103454.png" alt="rect" /></p>
<h2>Drawing Gradient Shapes</h2>
<pre name="code" class="java">
ShapeFactoryParameters b = new ShapeFactoryParameters();
b.x(50);
b.y(50);
b.w(300);
b.h(100);
b.color(0xffffffff);
b.kind("RECT");
b.gradientKind("CLAMP"); // "CLAMP", "REPEAT" "MIRROR"
b.gradientColor1(Color.WHITE); // initial color
b.gradientColor2(0xffff0000); // ending color
b.gradientStartX(50); // initial x
b.gradientStartY(50); // initial y
b.gradientEndX(200); // ending x
b.gradientEndY(100); // ending y
</pre>
<p><img src="http://www.marceloduende.com/blog/images/SC20110817-103558.png" alt="rect" /></p>
<h2>Drawing Shapes with dynamic width and height</h2>
<pre name="code" class="java">
View linearLayout = findViewById(R.id.YOUR_LAYOUT_ID); // add the layout ID right here
        ShapeFactoryParameters b = new ShapeFactoryParameters()
         			.x(0)
         			.y(0)
         			.w(WindowBoundaries.getWidth(YOUR_ACTIVITY)) // dynamic width
         			.h(WindowBoundaries.getHeight(YOUR_ACTIVITY)) // dynamic height
         			.color(0xffffffff)
         			.kind("RECT")
         			.gradientKind("CLAMP")
         			.gradientColor1(Color.WHITE)
         			.gradientColor2(0xffff0000)
         			.gradientStartX(0)
         			.gradientStartY(0)
         			.gradientEndX(WindowBoundaries.getWidth(YOUR_ACTIVITY)) // dynamic width
         			.gradientEndY(WindowBoundaries.getHeight(YOUR_ACTIVITY)); // dynamic height
        ShapeFactory sf = new ShapeFactory(this, b); // add the Activity
        ((LinearLayout) linearLayout).addView(sf);
</pre>
<p><img src="http://www.marceloduende.com/blog/images/SC20110817-113751.png" alt="rect" /></p>
<h2>App built with JZoo</h2>
<p>This app is about to be released next month. I&#8217;ll make a special post about it soon.</p>
<p><img src="http://www.marceloduende.com/blog/images/SC20110817-114133.png" alt="rect" /></p>
<h2>Parameters</h2>
<pre name="code" class="java">
// MANDATORY
x();
y();
h();
w();
color();
kind();

// RELATIVE
corner();
stroke();
alpha();
gradientKind(); // "CLAMP", "REPEAT" "MIRROR"
gradientColor1(); // int
gradientColor2(); // int
gradientStartX(); // int
gradientStartY(); // int
gradientEndX(); // int
gradientEndY(); // int
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.marceloduende.com/blog/?feed=rss2&#038;p=19</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What happened?</title>
		<link>http://www.marceloduende.com/blog/?p=16&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=what-happened</link>
		<comments>http://www.marceloduende.com/blog/?p=16#comments</comments>
		<pubDate>Mon, 15 Aug 2011 04:34:03 +0000</pubDate>
		<dc:creator>Marcelo Duende</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[internet]]></category>

		<guid isPermaLink="false">http://www.marceloduende.com/blog/?p=16</guid>
		<description><![CDATA[Seriously, what the hell happened? Where are the cool web sites experiences? Where are the projects which we loved to do? Where is the Coke Zero Game website? What the hell they&#8217;re doing with html5? ONLY STUPID EXPERIMENTS which nobody &#8230; <a href="http://www.marceloduende.com/blog/?p=16">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Seriously, what the hell happened?</p>
<p>Where are the cool web sites experiences? Where are the projects which we loved to do? Where is the <a href="http://demo.northkingdom.com/cokezerogame/www/index.html" target="_blank">Coke Zero Game</a> website?</p>
<p>What the hell they&#8217;re doing with html5? ONLY STUPID EXPERIMENTS which nobody can use, because these bullshits only work on the last super cool Chrome version. RETARDED!</p>
<p>What a egocentric person called Steve Jobs did to the world wide internet experience? I&#8217;m talking about internet, it encompasses mobile, desktops and whatever device that can run internet. He has simply killed a generation! Generation with amazing people that love to create crazy things. </p>
<p>I was part of this generation. I said, WAS!</p>
<p>What is cool now? I meant, cool, not useful! There&#8217;s a ton of useful apps at the Apple Store, which is great, but where&#8217;s the cool stuff?</p>
<p>I had to move on with the market. Doing petty things, because the client doesn&#8217;t want something that doesn&#8217;t run at iPad, iPhone, iSuck! At the end, the client is right. They&#8217;re lost in this war, they only want their brand at any device possible. How to do it? Stupid 1999 html projects which there&#8217;s NO excitement, none!</p>
<p>I have to say that I became a better developer with all this mess. I&#8217;ve learned couple new languages and ways to develop. I could be wrong, and I wanted to be wrong, but, to be honest, I&#8217;m pretty right and unhappy.</p>
<p>I really hope that html5 does become a real cool thing, because I like to do cool things. For now, it looks like crap for me, and commercially speaking, it is a huge crap.</p>
<p>I still can&#8217;t understand how Cannes could have named a Chrome experiment as the best choice for Cyber. What was the popularity of that thing? Who has launched that website? Only cool dudes with the new Chrome version? Cannes for hipsters, maybe? Should I grab my lion and throw out in the fog?</p>
<p>I don&#8217;t want to be old saying that, but I&#8217;d like to delivery something which all users could interact without restrictions, regardless the browser, the ONLY tool, that can provide this nowadays is the Flash.</p>
<p>Is it getting old? A&#8217;ight, so, can you show me something new that can do at least 50% that Flash does?</p>
<p>Again, I&#8217;m NOT a Flash defender, I don&#8217;t care about which technology will be used and I&#8217;m not biased with different technologies, don&#8217;t get me wrong, I JUST WANT TO DO COOL THINGS!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marceloduende.com/blog/?feed=rss2&#038;p=16</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>MouseWheel &#8211; Javascript</title>
		<link>http://www.marceloduende.com/blog/?p=14&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mousewheel-javascript</link>
		<comments>http://www.marceloduende.com/blog/?p=14#comments</comments>
		<pubDate>Wed, 20 Jul 2011 14:20:54 +0000</pubDate>
		<dc:creator>Marcelo Duende</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[mousewheel]]></category>
		<category><![CDATA[wheel]]></category>

		<guid isPermaLink="false">http://www.marceloduende.com/blog/?p=14</guid>
		<description><![CDATA[Hey ya&#8217;ll Last days I have the necessity to develop some work in html, using javascript and css and a lot more stuff. It&#8217;s been funny to be honest, I&#8217;m feeling pumped doing this kind of stuff, looks like I &#8230; <a href="http://www.marceloduende.com/blog/?p=14">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hey ya&#8217;ll</p>
<p>Last days I have the necessity to develop some work in html, using javascript and css and a lot more stuff. It&#8217;s been funny to be honest, I&#8217;m feeling pumped doing this kind of stuff, looks like I am 5 years in the past <img src='http://www.marceloduende.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>One thing that I never did before was to create a mouse wheel functionality in JS, thing that I was used to do in Actionscript.</p>
<p>Well, it is pretty straight forward, also I could easily save this code for future reuse, after some implementation, obviously.</p>
<p>I have tested this code in a couple browsers, looks like it is working pretty smooth.</p>
<pre name="code" class="javascript">
/**
* @author Marcelo Duende
*
* This is a MouseWheel utility which allows you to scroll your content in any browser
*
* The license is FREE it does mean FREEEEEEE!
*
* Contact
* marceloduende.com
* marceloduende.com/blog
* marcelo.duende@gmail.com
*
*/

/**
* Adding event listener
*/
if (window.addEventListener)
	window.addEventListener('DOMMouseScroll', wheelHandle, false); /** Mozilla. */
	window.onmousewheel = document.onmousewheel = wheelHandle; /** IE - Opera. */

/**
* Handling div
*/
function handlingDelta(delta){
	/** kill default actions.*/
	if (event.preventDefault)
		event.preventDefault();
		event.returnValue = false;

	document.getElementById("your_elemet_here").scrollTop += -delta*2; /**throw your element there to start the mouse wheeling*/
}

/**
* Handling Delta value
*/
function wheelHandle(event){
	var deltaValue = 0;

	if (!event) /** For IE. */
		event = window.event;

	if(event.wheelDelta){ /** IE - Opera. */
		deltaValue = event.wheelDelta/120;

		if(window.opera) /** Opera 9. */
			deltaValue = -deltaValue;

	} else if(event.detail){/** Mozilla. In Mozilla delta is multiple of 3 */
		deltaValue = -event.detail/3;
	}

	if (deltaValue)
		handlingDelta(deltaValue);

}
</pre>
<p>Also, you need a html for this, I&#8217;ll copy and paste my code quickly, as the focus of this post, is to teach only the JS.</p>
<pre name="code" class="html">

<html>
	<head>
<link href="css/style.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="js/mouse_wheel.js"></script>
    </head>

    <body>
<div id="scroll_window" class="center_div">
<ul>
<li>marcelo</li>
<li>duende</li>
<li>marcelo</li>
<li>duende</li>
<li>marcelo</li>
<li>duende</li>
<li>marcelo</li>
<li>duende</li>
<li>marcelo</li>
<li>duende</li>
</ul></div>
<div id="test" class="center_div">
<ul>
<li><a href="marceloduende.com">Scroll around with the mouse wheel</a></li>
</ul></div>

    </body>
</html>
</pre>
<p>And the CSS.</p>
<pre name="code" class="css">
@charset "UTF-8";
/* CSS Document */

.center_div{
	width:50%;
	height:100px;
	margin:auto;
	position:relative;
	overflow-y:hidden;
	overflow-x:auto;
}
#scroll_window ul{
	list-style-type:none;
	height:50px;
	width:200px;
	margin:auto;
}
#scroll_window li{
	float:left;
	padding:20px;
}

#test ul{
	list-style-type:none;
	height:50px;
	width:200px;
	margin:auto;
}

#test li{
	float:left;
	padding:20px;
}
#test ul a:hover {
	color: #000000;
}

#test ul a{
	text-decoration:none;
	color:#FF0000;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.marceloduende.com/blog/?feed=rss2&#038;p=14</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Handling screen orientation change Android &#8211; Java</title>
		<link>http://www.marceloduende.com/blog/?p=9&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=handling-orientation-android-java</link>
		<comments>http://www.marceloduende.com/blog/?p=9#comments</comments>
		<pubDate>Wed, 15 Jun 2011 18:30:31 +0000</pubDate>
		<dc:creator>Marcelo Duende</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[change]]></category>
		<category><![CDATA[orientation]]></category>
		<category><![CDATA[screen]]></category>

		<guid isPermaLink="false">http://www.marceloduende.com/blog/?p=9</guid>
		<description><![CDATA[Sup guys, Last days I&#8217;ve faced a tiny problem with orientations inside my app. When you change the orientation while it is sending, downloading or even with saved data in your screen, it does restart the Activity alone, creating another &#8230; <a href="http://www.marceloduende.com/blog/?p=9">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sup guys,</p>
<p>Last days I&#8217;ve faced a tiny problem with orientations inside my app. When you change the orientation while it is sending, downloading or even with saved data in your screen, it does restart the Activity alone, creating another View for this new orientation. It is good in some cases, but sometimes it is a pain in the ass, crashing your app.</p>
<p>To block it, is pretty simple, you can block the new View and still fit your screen in both orientations (vertical and horizontal).</p>
<p>So just add this to your activity in AndroidManifest.xml</p>
<pre name="code" class="java">

android:configChanges="orientation"
</pre>
<p>And you are good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marceloduende.com/blog/?feed=rss2&#038;p=9</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Analytics for Android/Java</title>
		<link>http://www.marceloduende.com/blog/?p=7&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-analytics-for-androidjava</link>
		<comments>http://www.marceloduende.com/blog/?p=7#comments</comments>
		<pubDate>Sun, 15 May 2011 04:44:11 +0000</pubDate>
		<dc:creator>Marcelo Duende</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[ga]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google analytics]]></category>

		<guid isPermaLink="false">http://www.marceloduende.com/blog/?p=7</guid>
		<description><![CDATA[I know there&#8217;s some people out there with tricky problems with this thing. Well, the Google Analytics for android is under development, yet. It isn&#8217;t a done stuff, for this reason there&#8217;s some tricks to do. I gonna show in &#8230; <a href="http://www.marceloduende.com/blog/?p=7">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I know there&#8217;s some people out there with tricky problems with this thing.</p>
<p>Well, the Google Analytics for android is under development, yet. It isn&#8217;t a done stuff, for this reason there&#8217;s some tricks to do. I gonna show in only one class how to do it</p>
<pre name="code" class="java">
/**
 *
 * @author Marcelo Duende
 *
 * How to use it
 *
 * 1 - Download the Google Analytics JAR - http://code.google.com/mobile/analytics/download.html
 *
 * 2 - Change your AndroidManifest.xml, add this:
 * <!-- Used for install referrer tracking -->
 * <receiver android:name="com.google.android.apps.analytics.AnalyticsReceiver"
 *		android:exported="true">
 *		<intent-filter>
 *	    	<action android:name="com.android.vending.INSTALL_REFERRER" />
 *	    </intent-filter>
 * </receiver>
 *
 * PS: Put it inside this node:
 * <application android:icon="@drawable/icon" android:label="@string/app_name">
 * *******************************************************
 * *********************HERE*****************************
 * *******************************************************
 * </application>
 *
 * 3 - Don't forget to allow the internet connection in your AndroidManifest.xml
 * <uses-permission android:name="android.permission.INTERNET"></uses-permission>
 *
 * 4 - Call this class passing some string to save in your records
 * GA ga = new GA();
 * ga.init(this);
 * ga.trackPageView("/MyPage");
 *
 * 5 - DON'T FORGET TO CREATE YOUR ACCOUNT AND CHANGE THE CONSTANT CALLED "GOOGLE_ANALYTICS_ID" down there
 *
 * 6 - Have fun
 *
 */

package com.marceloduende.sickspot.ga;

import android.app.Activity;

import com.google.android.apps.analytics.GoogleAnalyticsTracker;

public class GA {

	/**
	 * Set tracker object
	 */
	public GoogleAnalyticsTracker tracker;

	/**
	 * Set Google Analytics ID
	 */
	// Change it to your Google Analytics ID
	public final String GOOGLE_ANALYTICS_ID = "UA-xxxx-x"; 

	/**
	 * Initiates the Google Analytics
	 * @param activity
	 */
	public void init(Activity activity){
		tracker = GoogleAnalyticsTracker.getInstance();
		tracker.start(GOOGLE_ANALYTICS_ID, activity);
		tracker.setCustomVar(1, "Medium", "Mobile App");
		tracker.dispatch();
	}

	/**
	 *
	 * Tracking Events
	 *
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 * @param arg3
	 */
	public void trackEvent(String arg0, String arg1, String arg2, int arg3){
		tracker.trackEvent(arg0, arg1, arg2, arg3);
	}

	/**
	 *
	 * Tracking Page Views
	 *
	 * @param arg0
	 */
	public void trackPageView(String arg0){
		tracker.trackPageView(arg0);
	}

	/**
	 *
	 * Stopping tracker
	 *
	 */
	public void trackerStop(){
		tracker.stop();
	}
}
</pre>
<p>If you need more info than this, here goes a useful link. <a href="http://code.google.com/mobile/analytics/docs/#mobilesdks" target="_blank">Developer&#8217;s guide </a></p>
<p>Enjoy <img src='http://www.marceloduende.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.marceloduende.com/blog/?feed=rss2&#038;p=7</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checking if the Wi-fi is turned on/off &#8211; Android/Java</title>
		<link>http://www.marceloduende.com/blog/?p=5&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=checking-if-the-wi-fi-is-turned-onoff</link>
		<comments>http://www.marceloduende.com/blog/?p=5#comments</comments>
		<pubDate>Fri, 13 May 2011 20:40:57 +0000</pubDate>
		<dc:creator>Marcelo Duende</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android wifi state]]></category>

		<guid isPermaLink="false">http://www.marceloduende.com/blog/?p=5</guid>
		<description><![CDATA[Sometimes you gotta have the Wi-fi connection turned on to execute some actions, as to get the location (LAT/LON). It can help you to get it more precisely. So to do it, the first thing you have to do is &#8230; <a href="http://www.marceloduende.com/blog/?p=5">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sometimes you gotta have the Wi-fi connection turned on to execute some actions, as to get the location (LAT/LON). It can help you to get it more precisely.</p>
<p>So to do it, the first thing you have to do is to open your AndroidManifest.xml and add this</p>
<pre name="code" class="xml">
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</pre>
<p>It gonna make you able to check your wifi state.</p>
<p>Then to check it, just do this</p>
<pre name="code" class="java">
WifiManager wifimanager = (WifiManager)this.getSystemService(Context.WIFI_SERVICE);
if (wifimanager.isWifiEnabled()){
// enabled
} else {
// disabled
}
</pre>
<p>Pretty simple, hun?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marceloduende.com/blog/?feed=rss2&#038;p=5</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uploading an image to a webserver &#8211; Android/Java</title>
		<link>http://www.marceloduende.com/blog/?p=1&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hello-world</link>
		<comments>http://www.marceloduende.com/blog/?p=1#comments</comments>
		<pubDate>Tue, 03 May 2011 14:14:34 +0000</pubDate>
		<dc:creator>Marcelo Duende</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[httpClient]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Uploading]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://www.marceloduende.com/blog/?p=1</guid>
		<description><![CDATA[Last week, I faced a problem to send an image to the server, I have tried a lot of ways, but seemed that nothing would work. After some research, I found the HTTPClient API , this API helped me to &#8230; <a href="http://www.marceloduende.com/blog/?p=1">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last week, I faced a problem to send an image to the server, I have tried a lot of ways, but seemed that nothing would work.</p>
<p>After some research, I found the <a href="http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/index.html" target="_blank">HTTPClient API</a> , this API helped me to do the dirty work, and it did pretty well. I will show you now, how to upload images and/or strings to the web server.</p>
<p>It&#8217;s pretty simple, actually. I gonna do in only one function!</p>
<p>&nbsp;</p>
<pre name="code" class="java">
// create a bitmap variable before anything;

private Bitmap bitmap;

// variable to set a name to the image into SD card;
// this variable, you have to put the path for the File, It's up to you;

public static String exsistingFileName;

// sendData is the function name, to call it, you can use something like sendData(null);
// remember to wrap it into a try catch;

public void sendData(String[] args) throws Exception {
	try {

		HttpClient httpClient = new DefaultHttpClient();
		HttpContext localContext = new BasicHttpContext();

		// here, change it to your php;

		HttpPost httpPost = new HttpPost("http://www.myURL.com/myPHP.php");
		MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
		bitmap = BitmapFactory.decodeFile(exsistingFileName);

		// you can change the format of you image compressed for what do you want;
		//now it is set up to 640 x 480;

		Bitmap bmpCompressed = Bitmap.createScaledBitmap(bitmap, 640, 480, true);
		ByteArrayOutputStream bos = new ByteArrayOutputStream();

		// CompressFormat set up to JPG, you can change to PNG or whatever you want;

		bmpCompressed.compress(CompressFormat.JPEG, 100, bos);
		byte[] data = bos.toByteArray();

		// sending a String param;

		entity.addPart("myParam", new StringBody("my value"));

		// sending a Image;
		// note here, that you can send more than one image, just add another param, same rule to the String;

		entity.addPart("myImage", new ByteArrayBody(data, "temp.jpg"));

		httpPost.setEntity(entity);
		HttpResponse response = httpClient.execute(httpPost, localContext);
		BufferedReader reader = new BufferedReader(new InputStreamReader( response.getEntity().getContent(), "UTF-8"));
		String sResponse = reader.readLine();

	} catch (Exception e) {

		Log.v("myApp", "Some error came up");

	}

}</pre>
<p>&nbsp;</p>
<p>And you should be good to go <img src='http://www.marceloduende.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.marceloduende.com/blog/?feed=rss2&#038;p=1</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

