<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Emanuele Feronato</title>
	
	<link>http://www.emanueleferonato.com</link>
	<description>italian geek and PROgrammer</description>
	<lastBuildDate>Sun, 08 Nov 2009 16:17:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/EmanueleFeronato" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Moved on a new server</title>
		<link>http://feedproxy.google.com/~r/EmanueleFeronato/~3/KSUe3vahgKk/</link>
		<comments>http://www.emanueleferonato.com/2009/11/08/moved-on-a-new-server/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 16:17:29 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Blogging]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1934</guid>
		<description><![CDATA[I am happy to annouce the blog has moved on a new server.
My old server, aruba.it, simply had too much problems to host a blog with high traffic, and as you probably experienced during the last days, the blog was hacked too much times.
The funny thing is every time I reported the problem to the [...]]]></description>
			<content:encoded><![CDATA[<p>I am happy to annouce the blog has moved on a new server.</p>
<p>My old server, <a href="http://www.aruba.it/" target = "_blank">aruba.it</a>, simply had too much problems to host a blog with high traffic, and as you probably experienced during the last days, the blog was hacked too much times.</p>
<p>The funny thing is every time I reported the problem to the customer care, they replied (normally after 24 hours, from monday to friday) it was my fault.</p>
<p>If I have a fault, is waiting that long before migrating (but I prefer to say &#8220;running away&#8221;)</p>
<p>Now I am hosted on <a target ="_blank" href="http://secure.hostgator.com/cgi-bin/affiliates/clickthru.cgi?id=triqui">HostGator</a> and finally I am back to life!!!</p>
<p>Since moving more than 6,000 files and about 25,000 queries can lead to some errors, I would like you to report any missing file or strange behavior to info[at]emanueleferonato.com</p>
<img src="http://feeds.feedburner.com/~r/EmanueleFeronato/~4/KSUe3vahgKk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/11/08/moved-on-a-new-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.emanueleferonato.com/2009/11/08/moved-on-a-new-server/</feedburner:origLink></item>
		<item>
		<title>60 Seconds to Fame Contest</title>
		<link>http://feedproxy.google.com/~r/EmanueleFeronato/~3/9Dlpuo1E0cA/</link>
		<comments>http://www.emanueleferonato.com/2009/11/07/60-seconds-to-fame-contest/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 22:39:13 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Contests]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Monetize]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1929</guid>
		<description><![CDATA[Once upon a time there was Flash Game Friday
It was a Flash Game contest held by Mochimedia, and the staff awarded one game a week a $100 prize for being awesome. There were no other rules and no theme. It was simply the staff choosing something they really enjoyed.
Now things changed. The original Flash Game [...]]]></description>
			<content:encoded><![CDATA[<p>Once upon a time there was <strong>Flash Game Friday</strong></p>
<p>It was a Flash Game contest held by <a target = "_blank" href="https://www.mochimedia.com/r/972ae333a3c92a2a">Mochimedia</a>, and the staff awarded one game a week a $100 prize for being awesome. There were no other rules and no theme. It was simply the staff choosing something they really enjoyed.</p>
<p>Now things changed. The original Flash Game Friday has now become a monthly contest!</p>
<p>Developers will have one month to develop a game based on a specific theme, and the monthly prize is <strong>$500</strong>.</p>
<p><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/3syt725z.jpg" /></p>
<p>Winners will be chosen from the eligible games by the <a target = "_blank" href="https://www.mochimedia.com/r/972ae333a3c92a2a">Mochi</a> staff.</p>
<p>The first monthly contest is <strong>60 Seconds to Fame</strong>.<span id="more-1929"></span></p>
<p><strong>Rules</strong>: Your game must be over/finished and ready for a score submission in 60 seconds or less. It does not matter how good you are in the game, it will still end in 60 seconds or less. The goal in these types of games is to push a user to get better, not so they can last longer, but rather get more points within that same time limit. It’s to spark the “oh, I get it,” or, “Maybe if I tried this…” in the player. Also, it’s to force a developer to stick to their idea without the fear of feature creep, which is often times a key factor in <a href="http://www.emanueleferonato.com/2008/03/17/wipe-the-vaporware-out-of-your-life/">causing your game to not be completed</a>.</p>
<p><strong>Deadline</strong>: December 4th, 2009 – 11:59PM PST</p>
<p><strong>Prizes</strong>: $400 for the winner, $50 each for two honorable mentions.</p>
<p>If you need some inspiration, on the <a href="http://mochiland.com/articles/november-2009-contest-60-seconds-to-fame" target = "_blank">official page</a> you can find six examples of games built around this theme. You will find all additional rules too.</p>
<img src="http://feeds.feedburner.com/~r/EmanueleFeronato/~4/9Dlpuo1E0cA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/11/07/60-seconds-to-fame-contest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.emanueleferonato.com/2009/11/07/60-seconds-to-fame-contest/</feedburner:origLink></item>
		<item>
		<title>The 20 best internet Flash games according to Telegraph</title>
		<link>http://feedproxy.google.com/~r/EmanueleFeronato/~3/OndXfWuYogM/</link>
		<comments>http://www.emanueleferonato.com/2009/11/05/the-20-best-internet-flash-games-according-to-telegraph/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 16:25:25 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1860</guid>
		<description><![CDATA[Telegraph is one of the most popular sites in the United Kingdom and ranked 279 worldwide according to Alexa (better than USA Today), so we can say it&#8217;s a quite an authority.
Some days ago it published an article about the best 20 Flash internet games.
Do you expect another chart seeing Bloons at the top? Big [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.telegraph.co.uk/" target = "_blank"><strong>Telegraph</strong></a> is one of the most popular sites in the United Kingdom and ranked 279 worldwide according to Alexa (better than USA Today), so we can say it&#8217;s a quite an authority.</p>
<p>Some days ago it published an article about <a target = "_blank" href="http://www.telegraph.co.uk/technology/video-games/6461245/The-20-best-internet-Flash-games-from-Doom-to-Stick-Cricket.html">the best 20 Flash internet games</a>.</p>
<p>Do you expect another chart seeing Bloons at the top? Big surprise, it isn&#8217;t in the list.</p>
<p>Let&#8217;s see what British casual gamers like:</p>
<p>1 &#8211; <a target = "_blank" href="http://www.officegamespot.com/flashgames/doom-triple-pack.htm"><strong>Doom Triple Pack</strong></a></p>
<p><a target = "_blank" href="http://www.officegamespot.com/flashgames/doom-triple-pack.htm"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele01.jpg" /></a></p>
<p>This should bring back some good memories from the original Doom, Hexen, and Heretic games. Doom Triple pack is a direct port of the original games using <a href="http://labs.adobe.com/technologies/alchemy/" target = "_blank">Adobe Alchemy</a> to convert the C code to actionscript.</p>
<p>I should give a try to Alchemy&#8230; any open source C game around there? </p>
<p>2 &#8211; <a target = "_blank" href="http://www.candystand.com/play/the-space-game"><strong>The Space Game</strong></a></p>
<p><a target = "_blank" href="http://www.candystand.com/play/the-space-game"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele02.jpg" /></a></p>
<p>This is a great space strategy game. Manage your energy, mine for minerals, expand, and defend yourself from space pirates. Reminded me Eve online</p>
<p>3 &#8211; <a target = "_blank" href="http://www.notdoppler.com/magicpen.php"><strong>Magic Pen</strong></a></p>
<p><a target = "_blank" href="http://www.notdoppler.com/magicpen.php"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele04.jpg" /></a></p>
<p>Guide the red ball to the goal in each level by creating shapes that interact with the physical environment. Great physics engine and cute graphics made this game a big success. The best drawing game after Line Rider, in my opinion<span id="more-1860"></span></p>
<p>4 &#8211; <a target = "_blank" href="http://www.thewayoftheninja.org/n_downloads.html"><strong>N</strong></a></p>
<p><a target = "_blank" href="http://www.thewayoftheninja.org/n_downloads.html"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele03.jpg" /></a></p>
<p>I played a lot this game about five years ago, or even more&#8230; incredible platform game&#8230; probably the best Flash game ever. It can&#8217;t be played online.</p>
<p>5 &#8211; <a target = "_blank" href="http://www.handdrawngames.com/DesktopTD/Game.asp"><strong>Desktop Tower Defense Pro</strong></a></p>
<p><a target = "_blank" href="http://www.handdrawngames.com/DesktopTD/Game.asp"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele05.jpg" /></a></p>
<p>The most successful Tower Defense game in my opinion </p>
<p>6 &#8211; <a target = "_blank" href="http://www.fugly.com/flash/819/flash-tetris.html"><strong>Tetris</strong></a></p>
<p><a target = "_blank" href="http://www.fugly.com/flash/819/flash-tetris.html"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele06.jpg" /></a></p>
<p>ehm&#8230; I know it&#8217;s a classic&#8230; but this version sucks&#8230; come on&#8230;</p>
<p>7 &#8211; <a target = "_blank" href="http://www.sticksports.com/cricket/index.php"><strong>Stick Cricket</strong></a></p>
<p><a target = "_blank" href="http://www.sticksports.com/cricket/index.php"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele07.jpg" /></a></p>
<p>Well&#8230; we all know Cricket is very popular in England. I have to say, I prefer Stick Football. Anyway, al games in the portal are good and funny and feature original leagues. You may like that site.</p>
<p>8 &#8211; <a target = "_blank" href="http://www.y8.com/games/Puzzle_Bobble"><strong>Puzzle Bobble</strong></a></p>
<p><a target = "_blank" href="http://www.y8.com/games/Puzzle_Bobble"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele08.jpg" /></a></p>
<p>It&#8217;s Puzzle Bobble&#8230; </p>
<p>9 &#8211; <a target = "_blank" href="http://www.channel4.com/4homes/play-win/games/mansion-impossible/"><strong>Mansion: Impossible</strong></a></p>
<p><a target = "_blank" href="http://www.channel4.com/4homes/play-win/games/mansion-impossible/"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele09.jpg" /></a></p>
<p>Seems something like Sim City but once you play it you realize it&#8217;s just a &#8220;whack a mole&#8221; game with a twist&#8230; click on the houses as soon as they appear on the market, and wait until they reach a good price.<br />
Then click again to sell them. That&#8217;s it.</p>
<p>10 &#8211; <a target = "_blank" href="http://www.mariogamesflash.com/super_mario_world_flash_game.html"><strong>Super Mario Flash</strong></a></p>
<p><a target = "_blank" href="http://www.mariogamesflash.com/super_mario_world_flash_game.html"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele10.jpg" /></a></p>
<p>Great Mario game by <a target = "_blank" href="http://www.nowereginald.be/index2.html">Nowe Reginald</a>. On his site you can find more Flash remakes of old classics. I have to say I don&#8217;t love fan games because they use copyrighted material and it&#8217;s a bit unclear whether is completely illegal or not.</p>
<p>11 &#8211; <a target = "_blank" href="http://www.wickedpissahgames.com/games/gravitypods/GravityPods.html"><strong>Gravity Pods</strong></a></p>
<p><a target = "_blank" href="http://www.wickedpissahgames.com/games/gravitypods/GravityPods.html"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele11.jpg" /></a></p>
<p>I remember this game having good reviews a couple of years ago&#8230; You have to shoot a missile and hit a target, but walls and gravity pods affect the trajectory. All in all an interesting puzzle game</p>
<p>12 &#8211; <a target = "_blank" href="http://www2.b3ta.com/realistic-internet-simulator/"><strong>Realistic Internet Simulator</strong></a></p>
<p><a target = "_blank" href="http://www2.b3ta.com/realistic-internet-simulator/"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele12.jpg" /></a></p>
<p>Closing unwanted popups is boring, but playing a game that puts you against unwanted popups is even more boring.</p>
<p>13 &#8211; <a target = "_blank" href="http://www.k2xl.com/games/boomshine/"><strong>Boomshine</strong></a></p>
<p><a target = "_blank" href="http://www.k2xl.com/games/boomshine/"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele13.jpg" /></a></p>
<p>It&#8217;s Boomshine&#8230; every Flash game player loved this game!</p>
<p>14 &#8211; <a target = "_blank" href="http://www.adobe.com/macromedia/holiday2004/"><strong>Penguin Jumping</strong></a></p>
<p><a target = "_blank" href="http://www.adobe.com/macromedia/holiday2004/"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele14.jpg" /></a></p>
<p>It&#8217;s a Macromedia (I repeat, Macromedia, not Adobe) holiday card game. Dated 2004. Fullstop.</p>
<p>15 &#8211; <a target = "_blank" href="http://www.play.vg/games/142-Tennis%20Game.html"><strong>Tennis Game</strong></a></p>
<p><a target = "_blank" href="http://www.play.vg/games/142-Tennis%20Game.html"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele15.jpg" /></a></p>
<p>Pretty simple tennis game, I don&#8217;t see the point in having it in this list.</p>
<p>16 &#8211; <a target = "_blank" href="http://www.clinical-virology.org/killerflu/killerflu.html"><strong>Killer Flu</strong></a></p>
<p><a target = "_blank" href="http://www.clinical-virology.org/killerflu/killerflu.html"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele16.jpg" /></a></p>
<p>Developed by the <a target = "_blank" href="http://www.clinical-virology.org/">UK Clinical Virology Network</a>, its quite an actual theme due to the swine H1N1 outbreak. Here is a game that allows you to learn more about how the influenza virus is transmitted and how it changes every year &#8211; which explains why you can get more than one dose of the flu over your lifetime and why vaccines need changing every year. </p>
<p>The game uses real world parameters to help us to understand why pandemic flu is a bit different to normal yearly (seasonal) flu.</p>
<p>Remember: even pandemic flu generally kills fewer people than you would think. Try to kill too many people in the game and see how difficult it is!</p>
<p>17 &#8211; <a target = "_blank" href="http://www.freerice.com/index.php"><strong>Free rice</strong></a></p>
<p><a target = "_blank" href="http://www.freerice.com/index.php"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele17.jpg" /></a></p>
<p>This is a charity game to support the <a target = "_blank" href="http://www.wfp.org/">United Nations World Food Program</a> Click on the right answer in the middle of this page, and for each answer you get right, 10 grains of rice will be donated to the United Nations World Food Program. As of today, <a href="http://www.freerice.com/totals.php" target = "_blank">over 70 billions</a> grains of rice have been raised&#8230; that means 7 billions of right answers&#8230; anyway the game is way more popular in the United States than in the United Kingdom&#8230;</p>
<p>18 &#8211; <a target = "_blank" href="http://www.sockandawe.com/"><strong>Sock and Awe!</strong></a></p>
<p><a target = "_blank" href="http://www.sockandawe.com/"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele18.jpg" /></a></p>
<p>Normally I don&#8217;t like politics games, and this one is not going to change my mind. Inspired by the accident seeing an <a target = "_blank" href="http://edition.cnn.com/2008/WORLD/meast/12/14/bush.iraq/index.html">Iraqi journalist throws shoes at Bush in Baghdad</a>, it&#8217;s just an above average point and click game.</p>
<p>19 &#8211; <a target = "_blank" href="http://www.helicoptergame.net/"><strong>Helicopter Game</strong></a></p>
<p><a target = "_blank" href="http://www.helicoptergame.net/"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele19.jpg" /></a></p>
<p>One button game similar to <a href="http://www.emanueleferonato.com/2008/01/18/create-a-flash-game-like-metro-siberia-underground/">Metro Siberia Underground</a> with the only difference Helicopter Game really sucks.. Really.</p>
<p>20 &#8211; <a target = "_blank" href="http://jiggmin.com/play_game.php?game=the_Game_of_Disorientation"><strong>The game of Disorientatio</strong>n</a></p>
<p><a target = "_blank" href="http://jiggmin.com/play_game.php?game=the_Game_of_Disorientation"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/tele20.jpg" /></a></p>
<p>I remember this one&#8230; a couple of years ago I played some levels and had some fun with all the way the game tries to disorientate the player. All in all it was a nice concept I am not seeing around for a while&#8230; Maybe I can write some tutorials about it&#8230;</p>
<p>And that&#8217;s what British players like.</p>
<p>Do you agree? Are you from England and play something else?</p>
<img src="http://feeds.feedburner.com/~r/EmanueleFeronato/~4/OndXfWuYogM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/11/05/the-20-best-internet-flash-games-according-to-telegraph/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<feedburner:origLink>http://www.emanueleferonato.com/2009/11/05/the-20-best-internet-flash-games-according-to-telegraph/</feedburner:origLink></item>
		<item>
		<title>Creating a Flash Facebook application with the Facebook Actionscript API</title>
		<link>http://feedproxy.google.com/~r/EmanueleFeronato/~3/kyqBvpCVzTY/</link>
		<comments>http://www.emanueleferonato.com/2009/11/04/creating-a-flash-facebook-application-with-the-facebook-actionscript-api/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 00:11:33 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Php]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1851</guid>
		<description><![CDATA[It&#8217;s time to see how can we build a Flash Facebook application.
What we are going to do is a Flash movie to be embedded in a Facebook application, able to interact with the user by publishing notes and stories on the wall.
The first thing we need is the official Facebook Actionscript API. This library contains [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time to see how can we build a Flash Facebook application.</p>
<p>What we are going to do is a Flash movie to be embedded in a Facebook application, able to interact with the user by publishing notes and stories on the wall.</p>
<p>The first thing we need is the official <a target = "_blank" href="http://code.google.com/p/facebook-actionscript-api/">Facebook Actionscript API</a>. This library contains all we need to create a complete Facebook Flash application.</p>
<p>You can download the source code at <a href="http://facebook-actionscript-api.googlecode.com/files/Facebook_library_v3.3_source.zip">this link</a>, but before messing with AS3, let&#8217;s create the PHP part.</p>
<p>I suggest you to read the <a href="http://www.emanueleferonato.com/2009/09/20/developing-a-facebook-application-for-absolute-beginners/">Developing a Facebook Application for absolute beginners</a> posts from <a href="http://www.emanueleferonato.com/2009/09/20/developing-a-facebook-application-for-absolute-beginners/">1</a> to <a href="http://www.emanueleferonato.com/2009/10/09/developing-a-facebook-application-for-absolute-beginners-step-5/">5</a> if you don&#8217;t know how to create a basic Facebook application.</p>
<p>Then, take a look at the PHP code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;">&lt;style&gt;
     <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #990000;">echo</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;style.css&quot;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/style&gt;
&nbsp;
&lt;script&gt;
     function grant() {
         document.setLocation(&quot;http://apps.facebook.com/flash_demo/&quot;);
     }
&lt;/script&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">&quot;facebook.php&quot;</span>;
&nbsp;
<span style="color: #000088;">$appapikey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;xxxxxxx&quot;</span>;
<span style="color: #000088;">$appsecret</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;yyyyyy&quot;</span>;
&nbsp;
<span style="color: #000088;">$facebook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Facebook<span style="color: #009900;">&#40;</span><span style="color: #000088;">$appapikey</span><span style="color: #339933;">,</span> <span style="color: #000088;">$appsecret</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$user_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">require_login</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$has_permission</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$facebook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">api_client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">users_hasAppPermission</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;publish_stream&quot;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$has_permission</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;div class = &quot;allow&quot;&gt;You won't be able to test the flash demo if you don't allow publish stream permission -
&nbsp;
&lt;fb:prompt-permission perms=&quot;publish_stream&quot; next_fbjs=&quot;grant()&quot;&gt;&lt;strong&gt;ALLOW PERMISSION&lt;/strong&gt;&lt;/fb:prompt-permission&gt;&lt;/div&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;fb:swf swfsrc=&quot;http://www.gamemummy.com/facebook/flash_demo/facebook_demo.swf&quot; allowscriptaccess=&quot;always&quot; bgcolor=&quot;#ffffff&quot; flashvars=&quot;&quot; width=&quot;500&quot; height=&quot;400&quot;/&gt;</pre></td></tr></table></div>

<p>Notice at <strong>lines 1-3</strong> the way you can import CSS style sheets. Don&#8217;t forget to use <code>htmlentities</code> on the imported file.</p>
<p>Then, at <strong>lines 5-9</strong> I created a simple javascript function called <code>grant</code> that just redirects the browser to the application page. That is, basically it refreshes the page, and it will be called once the user will grant (or won&#8217;t grant) the permission to publish contents on his wall by submitting the permission form as you can see at <strong>line 30</strong>.</p>
<p>This is possible thanks to <code>next_fbjs="grant()"</code>.</p>
<p>Another important thing in this script you should arleady know is the way I ask for publishing permission.</p>
<p>You can ask for permission inside the Flash movie itself but I found it easier to ask directly from Php. This way, you can even hide the Flash movie if the user does not grant permissions.</p>
<p>But the core of the script, the think you did not see in previous tutorials is the way I include the Flash movie at <strong>line 34</strong> with the <code>fb:swf</code> tag.</p>
<p>You can find the official documentation at <a target = "_blank" href="http://wiki.developers.facebook.com/index.php/Fb:swf">this page</a>, and the most interesting thing is Facebook is passing some interesting parameters to the movie.<span id="more-1851"></span></p>
<p>Let&#8217;s see the Actionscript now&#8230; I used the button component to create the buttons but this is not important&#8230; here it is the commented script:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> fl.controls.Button;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<span style="color: #004993;">TextField</span>;
	<span style="color: #009900;">// facebook rlibraries</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.facebook.Facebook;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.facebook.utils.FacebookSessionUtil;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.facebook.commands.notifications.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.facebook.commands.stream.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.facebook.net.FacebookCall;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> facebook_demo extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> text_field<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">TextField</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #6699cc; font-weight: bold;">var</span> my_button<span style="color: #000000; font-weight: bold;">:</span>Button;
		<span style="color: #6699cc; font-weight: bold;">var</span> fbook<span style="color: #000000; font-weight: bold;">:</span>Facebook;
		<span style="color: #009900;">// these are the api and secret keys you should be used to</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> api_key<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>=<span style="color: #990000;">&quot;xxxxxxxxxxxxxxx&quot;</span>;
		<span style="color: #6699cc; font-weight: bold;">var</span> secret_key<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>=<span style="color: #990000;">&quot;yyyyyyyyyyyyyyyy&quot;</span>;
		<span style="color: #009900;">// starting a new facebook session</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> fb_session<span style="color: #000000; font-weight: bold;">:</span>FacebookSessionUtil=<span style="color: #0033ff; font-weight: bold;">new</span> FacebookSessionUtil<span style="color: #000000;">&#40;</span>api_key,secret_key,<span style="color: #004993;">loaderInfo</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #009900;">// in this object I will store all variables Facebook will pass to the movie</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> passed_vars<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>;
		<span style="color: #009900;">// this variable will hold all facebook API calls</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> fbcall<span style="color: #000000; font-weight: bold;">:</span>FacebookCall;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> facebook_demo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// just placing some buttons...</span>
			place_buttons<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// just creating a text field...</span>
			create_text_field<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// initializing the session</span>
			fbook=fb_session.facebook;
			<span style="color: #009900;">// this function will just print out all variables Facebook is passing to the movie</span>
			get_vars<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// this is the core function, the one that will handle clicks on buttons and publising notes or stories according</span>
		<span style="color: #009900;">// to the button I am pressing</span>
		<span style="color: #339966; font-weight: bold;">function</span> onclick<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// retrieving the user id (it's one of the variables passed by Facebook)</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> uid<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #004993;">Number</span><span style="color: #000000;">&#40;</span>passed_vars<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;fb_sig_user&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">switch</span> <span style="color: #000000;">&#40;</span>event.<span style="color: #004993;">currentTarget</span>.label<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">&quot;Publish a note&quot;</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #009900;">// publishing a note</span>
					fbcall=<span style="color: #0033ff; font-weight: bold;">new</span> SendNotification<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>uid<span style="color: #000000;">&#93;</span>,<span style="color: #990000;">&quot;just sent a self-notification using &lt;a href = <span style="">\&quot;</span>http://apps.facebook.com/flash_demo/<span style="">\&quot;</span>&gt;Facebook Flash Demo&lt;/a&gt;&quot;</span>,<span style="color: #990000;">&quot;user_to_user&quot;</span><span style="color: #000000;">&#41;</span>;
					fbook.post<span style="color: #000000;">&#40;</span>fbcall<span style="color: #000000;">&#41;</span>;
					<span style="color: #0033ff; font-weight: bold;">break</span>;
				<span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #990000;">&quot;Publish a story&quot;</span> <span style="color: #000000; font-weight: bold;">:</span>
					<span style="color: #009900;">// publishing a story</span>
					fbcall=<span style="color: #0033ff; font-weight: bold;">new</span> PublishPost<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;is using Facebook Flash Demo&quot;</span>,<span style="color: #000000;">&#123;</span><span style="color: #990000;">'href'</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #990000;">'http://apps.facebook.com/flash_demo/'</span>,<span style="color: #990000;">'name'</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #990000;">'Facebook Flash Demo'</span>,<span style="color: #990000;">'description'</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #990000;">'that<span style="">\'</span>s it'</span>,<span style="color: #990000;">'caption'</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #990000;">'this image was published by a Flash Movie'</span>,<span style="color: #990000;">'media'</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#123;</span><span style="color: #990000;">'type'</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">'image'</span>,<span style="color: #990000;">'src'</span><span style="color: #000000; font-weight: bold;">:</span>  <span style="color: #990000;">'http://www.gamemummy.com/facebook/flash_demo/api.jpg'</span>, <span style="color: #990000;">'href'</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">'http://apps.facebook.com/flash_demo/'</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#125;</span>,<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#123;</span><span style="color: #990000;">'href'</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #990000;">'http://apps.facebook.com/flash_demo/'</span>,<span style="color: #990000;">'text'</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #990000;">'Visit Facebook Flash Demo'</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#93;</span>,uid.<span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
					fbook.post<span style="color: #000000;">&#40;</span>fbcall<span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #339966; font-weight: bold;">function</span> create_text_field<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>text_field<span style="color: #000000;">&#41;</span>;
			text_field.<span style="color: #004993;">width</span>=<span style="color: #000000; font-weight:bold;">500</span>;
			text_field.<span style="color: #004993;">height</span>=<span style="color: #000000; font-weight:bold;">320</span>;
			text_field.<span style="color: #004993;">x</span>=<span style="color: #000000; font-weight:bold;">10</span>;
			text_field.<span style="color: #004993;">y</span>=<span style="color: #000000; font-weight:bold;">10</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #339966; font-weight: bold;">function</span> get_vars<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> varname<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> varvalue<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>;
			passed_vars=<span style="color: #004993;">root</span>.<span style="color: #004993;">loaderInfo</span>.<span style="color: #004993;">parameters</span>;
			text_field.<span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;DEFAULT VARS PASSED BY FACEBOOK:<span style="">\n</span><span style="">\n</span>&quot;</span>;
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>varname <span style="color: #0033ff; font-weight: bold;">in</span> passed_vars<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				varvalue=<span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span>passed_vars<span style="color: #000000;">&#91;</span>varname<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;
				text_field.<span style="color: #004993;">appendText</span><span style="color: #000000;">&#40;</span>varname <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;:<span style="">\t</span>&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> varvalue <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #339966; font-weight: bold;">function</span> place_buttons<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> bnames<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Publish a note&quot;</span>,<span style="color: #990000;">&quot;Publish a story&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=0; i<span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #000000; font-weight:bold;">2</span>; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				my_button=<span style="color: #0033ff; font-weight: bold;">new</span> Button<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>my_button<span style="color: #000000;">&#41;</span>;
				my_button.label=bnames<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>;
				my_button.move<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">125</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">150</span><span style="color: #000000; font-weight: bold;">*</span>i, <span style="color: #000000; font-weight:bold;">350</span><span style="color: #000000;">&#41;</span>;
				my_button.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>, onclick<span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>The interesting thing of this script is the way you can send notifications (<strong>line 44</strong>) and publish posts (<strong>line 49</strong>)&#8230; I won&#8217;t talk about notifications because <a href="http://wiki.developers.facebook.com/index.php/Notifications.send" target = "_blank">Facebook will deprecate this method in late November/early December 2009</a> , but I want you to look at the way I publish the post following the format explained at the <a href="http://wiki.developers.facebook.com/index.php/Attachment_%28Streams%29" target = "_blank">official attachment docs</a>.</p>
<p>You can <a href="http://apps.facebook.com/flash_demo/" target = "_blank">test the application at this page</a> and <a href="/downloads/facebook_demo.zip">download the full source code</a>, library included.</p>
<p>Next time, we&#8217;ll see how to add more functions.</p>
<img src="http://feeds.feedburner.com/~r/EmanueleFeronato/~4/kyqBvpCVzTY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/11/04/creating-a-flash-facebook-application-with-the-facebook-actionscript-api/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.emanueleferonato.com/2009/11/04/creating-a-flash-facebook-application-with-the-facebook-actionscript-api/</feedburner:origLink></item>
		<item>
		<title>Social Gold releases Secure In-Game Payments for Flash</title>
		<link>http://feedproxy.google.com/~r/EmanueleFeronato/~3/xHO-xLaNTXY/</link>
		<comments>http://www.emanueleferonato.com/2009/11/03/social-gold-releases-secure-in-game-payments-for-flash/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 10:11:21 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Monetize]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1845</guid>
		<description><![CDATA[Are you looking for a payment method completely embedded into your Flash game/app? Then Social Gold might be your choice.
I&#8217;ve been in contact for a while with Vikas Gupta and Michael Haswell, and I am sharing with you some relevant information about this brand new service:
Jambool, Inc., operator of leading virtual currency and payments platform [...]]]></description>
			<content:encoded><![CDATA[<p>Are you looking for a payment method completely embedded into your Flash game/app? Then <strong>Social Gold</strong> might be your choice.</p>
<p>I&#8217;ve been in contact for a while with <strong>Vikas Gupta</strong> and <strong>Michael Haswell</strong>, and I am sharing with you some relevant information about this brand new service:</p>
<p><a href="http://www.jambool.com/" target = "_blank">Jambool, Inc.</a>, operator of leading virtual currency and payments platform Social Gold™, announced the launch of the first completely secure, <strong>completely in-Flash payments solution</strong>, Social Gold for Flash.</p>
<p>As you can see in this picture, the whole payment UI is embedded in the flash game</p>
<p><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/11/social01.jpg" /></p>
<p>Social Gold for Flash is a patent-pending technology for processing payments securely, directly within Flash games. Existing payment options for Flash break the in-game experience, by requiring the user to navigate to a separate web page in order to make a purchase. This often results in the user losing game state and having to refresh the game. Or, in the worst case, a user might not return to the Flash game at all. Because users never leave the Flash game, Social Gold for Flash drives engagement and, ultimately, conversion.<span id="more-1845"></span></p>
<p>“As more and more publishers move to Flash, a secure, in-Flash payments experience has been high on our partners? wish lists. Nobody has been able to deliver a deeply-integrated and secure solution, until now,” said <strong>Vikas Gupta</strong>, founder and CEO of Jambool. “Social Gold for Flash is the first and only secure, in-Flash payments solution. We are excited to deliver this innovation to our partners.”</p>
<p>Some of the largest Flash games on Facebook have integrated Social Gold for Flash. RealGames™, the games division of RealNetworks®, Inc., recently launched it within Uno™, while TheBroth, Inc. recently launched Social Gold for Flash within Barn Buddy.</p>
<p>“We obsess over user engagement, and traditional monetization solutions kill engagement,“ said Markus Weichselbaum, CEO of TheBroth and creator of Barn Buddy, a game with nearly seven million monthly active users. “Social Gold for Flash works great for us, keeping our users engaged while helping to drive increased revenue. It is a great payments solution to keep users within the game.”</p>
<p>Developers who want to integrate the Social Gold for Flash API can register at <a href="http://www.getsocialgold.com/" target = "_blank">http://getsocialgold.com</a>.</p>
<p><strong>About Jambool</strong></p>
<p>Jambool operates Social Gold, a leading virtual currency and payments platform for social games and applications. The platform enables developers to create and manage their own white-labeled virtual currency, to provide an unparalleled, in-app payments experience to their users, and to optimize their virtual economy using robust analytics.</p>
<p>Some of the largest social applications use Social Gold, but its easy-to-integrate APIs allow even the smallest applications to launch a virtual economy in a matter of hours. Jambool was founded by Vikas Gupta and Reza Hussein, both Amazon.com veterans, and has offices in San Francisco and Seattle. For more information, please visit <a href="http://www.jambool.com/" target = "_blank">http://www.jambool.com</a>.</p>
<p>This is a video showing the power of Social Gold</p>
<p><object width="520" height="417"><param name="movie" value="http://www.youtube.com/v/P9for-yYYF0&#038;hl=it&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/P9for-yYYF0&#038;hl=it&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="520" height="417"></embed></object></p>
<p>I can&#8217;t wait to use it in one of my projects, so expect a in-depth review very soon.</p>
<img src="http://feeds.feedburner.com/~r/EmanueleFeronato/~4/xHO-xLaNTXY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/11/03/social-gold-releases-secure-in-game-payments-for-flash/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://www.emanueleferonato.com/2009/11/03/social-gold-releases-secure-in-game-payments-for-flash/</feedburner:origLink></item>
		<item>
		<title>Triqui’s picks #3</title>
		<link>http://feedproxy.google.com/~r/EmanueleFeronato/~3/VI75IX9f_60/</link>
		<comments>http://www.emanueleferonato.com/2009/11/01/triquis-picks-3/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 11:41:50 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1835</guid>
		<description><![CDATA[Only 7 games this week, a lot of useless Halloween games flooded the entries.
Anyway:
Drop3: Interesting mix between Tetris and &#8220;match shapes with the same color&#8221; game with real world Physics.
What I liked: quite original idea
Programming difficulty: Box2D and contact listener. 1/5
Sniper Year 2: playing as a sniper, you have to kill your targets in different [...]]]></description>
			<content:encoded><![CDATA[<p>Only 7 games this week, a lot of useless Halloween games flooded the entries.</p>
<p>Anyway:</p>
<p><a href="http://www.triqui.com/2009/10/30/drop3/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/drop3/_thumb_100x100.png" title="Drop3" /></a><a href="http://www.triqui.com/2009/10/30/drop3/" target = "_blank"><strong>Drop3</strong></a>: Interesting mix between Tetris and &#8220;match shapes with the same color&#8221; game with real world Physics.</p>
<p><strong>What I liked</strong>: quite original idea</p>
<p><strong>Programming difficulty</strong>: Box2D and contact listener. <strong>1/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/30/sniper-year-2/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/sniper-year-2/_thumb_100x100.jpg" title="Sniper Year 2" /></a><a href="http://www.triqui.com/2009/10/30/sniper-year-2/" target = "_blank"><strong>Sniper Year 2</strong></a>: playing as a sniper, you have to kill your targets in different ways, sometimes in stealth mode, sometimes in a crowded yacht</p>
<p><strong>What I liked</strong>: the graphic and the overall feeling.</p>
<p><strong>Programming difficulty</strong>: a mask and some hit tests&#8230; <strong>1/5</strong><span id="more-1835"></span></p>
<p><a href="http://www.triqui.com/2009/10/30/ketinetto-4/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/ketinetto-4/_thumb_100x100.jpg" title="Ketinetto 4" /></a><a href="http://www.triqui.com/2009/10/30/ketinetto-4/" target = "_blank"><strong>Ketinetto 4</strong></a>: Interesting graphic adventure, escape from an abandoned ship</p>
<p><strong>What I liked</strong>: the Monkey Island feeling</p>
<p><strong>Programming difficulty</strong>: it&#8217;s just point and click and some scripted pathfinding. <strong>2/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/28/fat-moon-cannon/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/fat-moon-cannon/_thumb_100x100.png" title="Fat Moon Cannon" /></a><a href="http://www.triqui.com/2009/10/28/fat-moon-cannon/" target = "_blank"><strong>Fat Moon Cannon</strong></a>: Destroy the buildings with your cannon and kill black aliens</p>
<p><strong>What I liked</strong>: I love original physics games</p>
<p><strong>Programming difficulty</strong>: Box2d an a little scrolling-zooming&#8230; <strong>2/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/26/cover-orange/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/cover-orange/_thumb_100x100.png" title="Cover Orange" /></a><a href="http://www.triqui.com/2009/10/26/cover-orange/" target = "_blank"><strong>Cover Orange</strong></a>: Protect your orange from a killing rain by placing objects in the right place</p>
<p><strong>What I liked</strong>: As said, I love original physics games&#8230; and this is very original</p>
<p><strong>Programming difficulty</strong>: basic Box2D functions&#8230; <strong>2/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/26/hell-tour/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/hell-tour/_thumb_100x100.jpg" title="Hell Tour" /></a><a href="http://www.triqui.com/2009/10/26/hell-tour/" target = "_blank"><strong>Hell Tour</strong></a>: a curious RPG with cute graphics. Explore the hell, buy items in the shop, kill enemies and earn money.</p>
<p><strong>What I liked</strong>: its&#8217; funny!</p>
<p><strong>Programming difficulty</strong>: managing upgrades, hit points and so on requires great attention with variables <strong>3/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/26/fashion-star/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/fashion-star_v5/_thumb_100x100.png" title="Fashion star" /></a><a href="http://www.triqui.com/2009/10/26/fashion-star/" target = "_blank"><strong>Fashion Star</strong></a>: Take cute little girls to the right places before they get annoyed and solve minigames</p>
<p><strong>What I liked</strong>: The overall design</p>
<p><strong>Programming difficulty</strong>: Each minigame could be a standalone game. And there is the main game too&#8230; <strong>3/5</strong></p>
<p>See you next week</p>
<img src="http://feeds.feedburner.com/~r/EmanueleFeronato/~4/VI75IX9f_60" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/11/01/triquis-picks-3/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://www.emanueleferonato.com/2009/11/01/triquis-picks-3/</feedburner:origLink></item>
		<item>
		<title>Creation of a Flash Stabilize! clone using Box2D – part 2</title>
		<link>http://feedproxy.google.com/~r/EmanueleFeronato/~3/ByHY10PTfj8/</link>
		<comments>http://www.emanueleferonato.com/2009/10/29/creation-of-a-flash-stabilize-clone-using-box2d-part-2/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 21:14:33 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Box2D]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1824</guid>
		<description><![CDATA[Time to add some new features to our Stabilize! clone we started in this post.
The features we&#8217;ll add this time are:
* Restricted area in which you can drop crates
* &#8220;Real&#8221; crates, made with a movieclip, take the place of the boxes you can draw with the mouse
As you can see, the script looks less and [...]]]></description>
			<content:encoded><![CDATA[<p>Time to add some new features to our <a target = "_blank" href="http://www.triqui.com/2009/10/10/stabilize/">Stabilize!</a> clone we started in <a href="http://www.emanueleferonato.com/2009/10/26/creation-of-a-flash-stabilize-clone-using-box2d-part-1/">this post</a>.</p>
<p>The features we&#8217;ll add this time are:</p>
<p>* Restricted area in which you can drop crates<br />
* &#8220;Real&#8221; crates, made with a movieclip, take the place of the boxes you can draw with the mouse</p>
<p>As you can see, the script looks less and less like the original <a href="http://www.emanueleferonato.com/2009/01/07/drawing-boxes-on-the-fly-on-box2d/">Drawing boxes on the fly in Box2D</a> and it&#8217;s starting to become a custom one.</p>
<p>To create the restricted area, I simply create the area movieclip and check if the mouse in inside such movieclip with <code>hitTestPoint</code> method.</p>
<p>It works with three parameters:</p>
<p><code>x</code>:Number &#8211; The x coordinate to test against this object.  </p>
<p><code> y</code>:Number -The y coordinate to test against this object. These coordinates are <code>mouseX</code> and <code>mouseY</code></p>
<p><code> shapeFlag</code>:Boolean (default = <code>false</code>) -Whether to check against the actual pixels of the object (<code>true</code>) or the bounding box (<code>false</code>). Obviously I want it to be <code>true</code></p>
<p>Here it is the source code:<span id="more-1824"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.Shapes.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #004993;">Math</span>.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> stabilize extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> m_sprite<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> m_world<span style="color: #000000; font-weight: bold;">:</span>b2World;
		<span style="color: #009900;">// the_crate is the crate sprite</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> the_crate<span style="color: #000000; font-weight: bold;">:</span>crate=<span style="color: #0033ff; font-weight: bold;">new</span> crate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #009900;">// droppable_area is the sprite representing the area your mouse</span>
		<span style="color: #009900;">// must overlap to drop a crate</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> droppable_area<span style="color: #000000; font-weight: bold;">:</span>drop_area = <span style="color: #0033ff; font-weight: bold;">new</span> drop_area<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> stabilize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> gravity<span style="color: #000000; font-weight: bold;">:</span>b2Vec2=<span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span>0,<span style="color: #000000; font-weight:bold;">9.8</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> worldAABB<span style="color: #000000; font-weight: bold;">:</span>b2AABB = <span style="color: #0033ff; font-weight: bold;">new</span> b2AABB<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			worldAABB.lowerBound.Set<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1000</span>,<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000000;">&#41;</span>;
			worldAABB.upperBound.Set<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1000</span>,<span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000000;">&#41;</span>;
			m_world=<span style="color: #0033ff; font-weight: bold;">new</span> b2World<span style="color: #000000;">&#40;</span>worldAABB,gravity,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
			m_sprite = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>m_sprite<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>droppable_area<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>the_crate<span style="color: #000000;">&#41;</span>;
			debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			AddBox<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">350</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,0,<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>;
			AddBox<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">350</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">20</span>,<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>,Update<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_DOWN</span>,mousePressed<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_MOVE</span>,mouseMoved<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> mousePressed<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// look at hitTestPoint... the final true value says it's going to to check against the actual pixels</span>
			<span style="color: #009900;">// instead of the bounding box</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>droppable_area.<span style="color: #004993;">hitTestPoint</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span>,<span style="color: #004993;">mouseY</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				AddBox<span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #004993;">mouseY</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">0.5</span>,<span style="color: #000000; font-weight:bold;">0.5</span>,<span style="color: #000000; font-weight:bold;">3</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> mouseMoved<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			the_crate.<span style="color: #004993;">x</span>=<span style="color: #004993;">mouseX</span>;
			the_crate.<span style="color: #004993;">y</span>=<span style="color: #004993;">mouseY</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>droppable_area.<span style="color: #004993;">hitTestPoint</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span>,<span style="color: #004993;">mouseY</span>,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				the_crate.<span style="color: #004993;">alpha</span>=<span style="color: #000000; font-weight:bold;">1</span>;
			<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
				the_crate.<span style="color: #004993;">alpha</span>=<span style="color: #000000; font-weight:bold;">0.5</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">// function AddBox</span>
		<span style="color: #009900;">// px: x position</span>
		<span style="color: #009900;">// py: y position</span>
		<span style="color: #009900;">// _halfwidth: half of the box width</span>
		<span style="color: #009900;">// _halfheight: half of the box height</span>
		<span style="color: #009900;">// density: density of the box (0: static)</span>
		<span style="color: #009900;">// is_crate: if true, it's a crate (and you should render the proper movieclip</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> AddBox<span style="color: #000000;">&#40;</span>px<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,py<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,_halfwidth<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,_halfheight<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,density<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,is_crate<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> bodyDef<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			bodyDef.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>px,py<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> boxDef<span style="color: #000000; font-weight: bold;">:</span>b2PolygonDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2PolygonDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			boxDef.SetAsBox<span style="color: #000000;">&#40;</span>_halfwidth,_halfheight<span style="color: #000000;">&#41;</span>;
			boxDef.density=density;
			boxDef.friction=<span style="color: #000000; font-weight:bold;">0.3</span>;
			boxDef.restitution=<span style="color: #000000; font-weight:bold;">0.2</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>is_crate<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				bodyDef.userData = <span style="color: #0033ff; font-weight: bold;">new</span> crate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> body<span style="color: #000000; font-weight: bold;">:</span>b2Body=m_world.CreateBody<span style="color: #000000;">&#40;</span>bodyDef<span style="color: #000000;">&#41;</span>;
			body.CreateShape<span style="color: #000000;">&#40;</span>boxDef<span style="color: #000000;">&#41;</span>;
			body.SetMassFromShapes<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>is_crate<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>bodyDef.userData<span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Update<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			m_world.Step<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> bb<span style="color: #000000; font-weight: bold;">:</span>b2Body = m_world.m_bodyList; bb; bb = bb.m_next<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>bb.m_userData <span style="color: #0033ff; font-weight: bold;">is</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
					bb.m_userData.<span style="color: #004993;">x</span>=bb.GetPosition<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">30</span>;
					bb.m_userData.<span style="color: #004993;">y</span>=bb.GetPosition<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">30</span>;
					bb.m_userData.<span style="color: #004993;">rotation</span> = bb.GetAngle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">180</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #004993;">Math</span>.<span style="color: #004993;">PI</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> dbgDraw<span style="color: #000000; font-weight: bold;">:</span>b2DebugDraw = <span style="color: #0033ff; font-weight: bold;">new</span> b2DebugDraw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> dbgSprite<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			m_sprite.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>dbgSprite<span style="color: #000000;">&#41;</span>;
			dbgDraw.m_sprite=m_sprite;
			dbgDraw.m_drawScale=<span style="color: #000000; font-weight:bold;">30</span>;
			dbgDraw.m_alpha=<span style="color: #000000; font-weight:bold;">1</span>;
			dbgDraw.m_fillAlpha=<span style="color: #000000; font-weight:bold;">0.5</span>;
			dbgDraw.m_lineThickness=<span style="color: #000000; font-weight:bold;">1</span>;
			dbgDraw.m_drawFlags=b2DebugDraw.e_shapeBit;
			m_world.SetDebugDraw<span style="color: #000000;">&#40;</span>dbgDraw<span style="color: #000000;">&#41;</span>;
&nbsp;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>And this is the result:</p>
<p><embed src="/downloads/stabilize2.swf" allowscriptaccess="always" menu="false" quality="high" width="500" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
<p>Click inside the red area to drop a crate</p>
<p>Download the <a href="/downloads/stabilize2.zip">source code</a>, Box2D library excluded</p>
<img src="http://feeds.feedburner.com/~r/EmanueleFeronato/~4/ByHY10PTfj8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/10/29/creation-of-a-flash-stabilize-clone-using-box2d-part-2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.emanueleferonato.com/2009/10/29/creation-of-a-flash-stabilize-clone-using-box2d-part-2/</feedburner:origLink></item>
		<item>
		<title>Horror Profile: Facebook application</title>
		<link>http://feedproxy.google.com/~r/EmanueleFeronato/~3/d-l_RvmEuCk/</link>
		<comments>http://www.emanueleferonato.com/2009/10/28/horror-profile-facebook-application/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 11:37:16 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Php]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1811</guid>
		<description><![CDATA[You are all invited to try Horror Profile, a Facebook application I made in about an hour.

The application takes your name and profile photo, and combines them in a creepy environment to create an horrific photo that you can upload to your album.
During next days I&#8217;ll release the full tutorial to create an application with [...]]]></description>
			<content:encoded><![CDATA[<p>You are all invited to try <a target = "_blank" href="http://apps.facebook.com/horror_name/"><strong>Horror Profile</strong></a>, a Facebook application I made in about an hour.</p>
<p><a target = "_blank" href="http://apps.facebook.com/horror_name/"><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/10/horror_profile.jpg" alt="horror_profile" title="horror_profile" /></a></p>
<p>The application takes your name and profile photo, and combines them in a creepy environment to create an horrific photo that you can upload to your album.</p>
<p>During next days I&#8217;ll release the full tutorial to create an application with ads, photo uploads, dynamic text generation, and all the features you see in the application.</p>
<p>Meanwhile, <a target = "_blank" href="http://apps.facebook.com/horror_name/"><strong>Play with it</strong></a>.</p>
<img src="http://feeds.feedburner.com/~r/EmanueleFeronato/~4/d-l_RvmEuCk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/10/28/horror-profile-facebook-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.emanueleferonato.com/2009/10/28/horror-profile-facebook-application/</feedburner:origLink></item>
		<item>
		<title>Creation of a Flash Stabilize! clone using Box2D – part 1</title>
		<link>http://feedproxy.google.com/~r/EmanueleFeronato/~3/Eo-eTPuWo-A/</link>
		<comments>http://www.emanueleferonato.com/2009/10/26/creation-of-a-flash-stabilize-clone-using-box2d-part-1/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 21:33:57 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Box2D]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1809</guid>
		<description><![CDATA[In Triqui&#8217;s picks 1 I told you Stabilize! is a good game to clone using Box2D.
And I would use this post to focus on another thing too&#8230; it&#8217;s about recycling.
I mean&#8230; once you code for a while, or follow developer&#8217;s blogs like this one providing a lot of source codes, probably most of the stuff [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.emanueleferonato.com/2009/10/18/triquis-picks-1/">Triqui&#8217;s picks 1</a> I told you <a target = "_blank" href="http://www.triqui.com/2009/10/10/stabilize/">Stabilize!</a> is a good game to clone using Box2D.</p>
<p>And I would use this post to focus on another thing too&#8230; it&#8217;s about recycling.</p>
<p>I mean&#8230; once you code for a while, or follow developer&#8217;s blogs like this one providing a lot of source codes, probably most of the stuff you need has already been written here and there.</p>
<p>In this case, the script we are going to modify is <a href="http://www.emanueleferonato.com/2009/01/07/drawing-boxes-on-the-fly-on-box2d/">Drawing boxes on the fly in Box2D</a>.</p>
<p>You will see we can make the whole game simply changing the original script step by step.</p>
<p>Coding this way will speed up your learning curve because you are starting from a working project so you don&#8217;t have to worry about the overall environment, and you can focus on small changes.</p>
<p>In this first step, we&#8217;ll just spend a couple of words about the balance bar.</p>
<p>It&#8217;s made up with a static object (the fulcrum) and a dynamic one (the bar).</p>
<p>In order to work, the density of the bar should be quite greater than the one of the falling boxes, or you&#8217;ll risk to lose the bar once the first box falls on it.<span id="more-1809"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
</pre></td><td class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">MouseEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Dynamics.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Collision.Shapes.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> Box2D.Common.<span style="color: #004993;">Math</span>.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> stabilize extends <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> m_sprite<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> m_world<span style="color: #000000; font-weight: bold;">:</span>b2World;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> initX<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0.0</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> initY<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0.0</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> drawing<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">false</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> stabilize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> gravity<span style="color: #000000; font-weight: bold;">:</span>b2Vec2=<span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span>0,<span style="color: #000000; font-weight:bold;">9.8</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> worldAABB<span style="color: #000000; font-weight: bold;">:</span>b2AABB = <span style="color: #0033ff; font-weight: bold;">new</span> b2AABB<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			worldAABB.lowerBound.Set<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1000</span>,<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000000;">&#41;</span>;
			worldAABB.upperBound.Set<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1000</span>,<span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000000;">&#41;</span>;
			m_world=<span style="color: #0033ff; font-weight: bold;">new</span> b2World<span style="color: #000000;">&#40;</span>worldAABB,gravity,<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
			m_sprite = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>m_sprite<span style="color: #000000;">&#41;</span>;
			debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			AddBox<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">350</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,0<span style="color: #000000;">&#41;</span>;
			AddBox<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">250</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">350</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">ENTER_FRAME</span>,Update<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_DOWN</span>,mousePressed<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_MOVE</span>,mouseMoved<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_UP</span>,mouseReleased<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> mousePressed<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">//Store initial X and Y position</span>
			initX=e.<span style="color: #004993;">localX</span>;
			initY=e.<span style="color: #004993;">localY</span>;
			drawing=<span style="color: #0033ff; font-weight: bold;">true</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> mouseMoved<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>drawing<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">//Simply draw the &quot;ghost&quot; of the box we are about to add</span>
				<span style="color: #004993;">graphics</span>.<span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0xFF0000,<span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span>initX,initY,e.localX<span style="color: #000000; font-weight: bold;">-</span>initX,e.localY<span style="color: #000000; font-weight: bold;">-</span>initY<span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> mouseReleased<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">graphics</span>.<span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			drawing=<span style="color: #0033ff; font-weight: bold;">false</span>;
&nbsp;
			<span style="color: #009900;">//Coordinates of bottom-right of box (when drawing from left to right)</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> finalX<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=e.<span style="color: #004993;">localX</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> finalY<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=e.<span style="color: #004993;">localY</span>;
&nbsp;
			<span style="color: #009900;">//Correct if drawing from right to left</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>finalX<span style="color: #000000; font-weight: bold;">&lt;</span>initX<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">//If so, swap initX and finalX</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> tempX<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=initX;
				initX=finalX;
				finalX=tempX;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>finalY<span style="color: #000000; font-weight: bold;">&lt;</span>initY<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">//If so, swap initY and finalY</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> tempY<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=initY;
				initY=finalY;
				finalY=tempY;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #009900;">//Work out the half-width and height of the box</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> boxHalfWidth<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>finalX<span style="color: #000000; font-weight: bold;">-</span>initX<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> boxHalfHeight<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>finalY<span style="color: #000000; font-weight: bold;">-</span>initY<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>boxHalfWidth<span style="color: #000000; font-weight: bold;">&gt;</span>0<span style="color: #000000; font-weight: bold;">&amp;&amp;</span>boxHalfHeight<span style="color: #000000; font-weight: bold;">&gt;</span>0<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				AddBox<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>finalX<span style="color: #000000; font-weight: bold;">-</span>boxHalfWidth<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000;">&#40;</span>finalY<span style="color: #000000; font-weight: bold;">-</span>boxHalfHeight<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,boxHalfWidth<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,boxHalfHeight<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #3f5fbf;">/*
		NOTE: AddBox takes the _x,_y and halfwidth and halfheight parameters
		in METRES not PIXELS. This means when you call this function, always
		DIVIDE a pixel size by 30 to get it in meteres.
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> AddBox<span style="color: #000000;">&#40;</span>_x<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,_y<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,_halfwidth<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,_halfheight<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>,density<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> bodyDef<span style="color: #000000; font-weight: bold;">:</span>b2BodyDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2BodyDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			bodyDef.<span style="color: #004993;">position</span>.Set<span style="color: #000000;">&#40;</span>_x,_y<span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> boxDef<span style="color: #000000; font-weight: bold;">:</span>b2PolygonDef = <span style="color: #0033ff; font-weight: bold;">new</span> b2PolygonDef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			boxDef.SetAsBox<span style="color: #000000;">&#40;</span>_halfwidth,_halfheight<span style="color: #000000;">&#41;</span>;
			boxDef.density=density;
			boxDef.friction=<span style="color: #000000; font-weight:bold;">0.3</span>;
			boxDef.restitution=<span style="color: #000000; font-weight:bold;">0.2</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> body<span style="color: #000000; font-weight: bold;">:</span>b2Body=m_world.CreateBody<span style="color: #000000;">&#40;</span>bodyDef<span style="color: #000000;">&#41;</span>;
			body.CreateShape<span style="color: #000000;">&#40;</span>boxDef<span style="color: #000000;">&#41;</span>;
			body.SetMassFromShapes<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Update<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">//We need to do this to simulate physics</span>
			m_world.Step<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">30</span>,<span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> debug_draw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> dbgDraw<span style="color: #000000; font-weight: bold;">:</span>b2DebugDraw = <span style="color: #0033ff; font-weight: bold;">new</span> b2DebugDraw<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> dbgSprite<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			m_sprite.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>dbgSprite<span style="color: #000000;">&#41;</span>;
			dbgDraw.m_sprite=m_sprite;
			dbgDraw.m_drawScale=<span style="color: #000000; font-weight:bold;">30</span>;
			dbgDraw.m_alpha=<span style="color: #000000; font-weight:bold;">1</span>;
			dbgDraw.m_fillAlpha=<span style="color: #000000; font-weight:bold;">0.5</span>;
			dbgDraw.m_lineThickness=<span style="color: #000000; font-weight:bold;">1</span>;
			dbgDraw.m_drawFlags=b2DebugDraw.e_shapeBit;
			m_world.SetDebugDraw<span style="color: #000000;">&#40;</span>dbgDraw<span style="color: #000000;">&#41;</span>;
&nbsp;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>And this is the result:</p>
<p><embed src="/downloads/stabilize.swf" allowscriptaccess="always" menu="false" quality="high" width="500" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></p>
<p>Draw boxes with your mouse and see how does the bar react.</p>
<p>No need to download anything, simply cut/paste the script you can find at <a href="http://www.emanueleferonato.com/2009/01/07/drawing-boxes-on-the-fly-on-box2d/">Drawing boxes on the fly in Box2D</a>.</p>
<p>Next time, we&#8217;ll manage &#8220;true&#8221; crates.</p>
<img src="http://feeds.feedburner.com/~r/EmanueleFeronato/~4/Eo-eTPuWo-A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/10/26/creation-of-a-flash-stabilize-clone-using-box2d-part-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.emanueleferonato.com/2009/10/26/creation-of-a-flash-stabilize-clone-using-box2d-part-1/</feedburner:origLink></item>
		<item>
		<title>Triqui’s picks #2</title>
		<link>http://feedproxy.google.com/~r/EmanueleFeronato/~3/ZG0P6va4BFs/</link>
		<comments>http://www.emanueleferonato.com/2009/10/25/triquis-picks-2/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 21:25:54 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1798</guid>
		<description><![CDATA[Let&#8217;s see the games I featured on triqui.com this week:
Zombie Taxi 2: Half Grand Theft Auto (the fist release), half Carmageddon, you have to rescue the people in the city before they become infected.
What I liked: the overall experience
Programming difficulty: Making a really clean and complete game is never easy. 4/5
Globulous Challenge: single player version [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s see the games I featured on <a href="http://www.triqui.com/" target = "_blank">triqui.com</a> this week:</p>
<p><a href="http://www.triqui.com/2009/10/23/zombie-taxi-2/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/zombie-taxi-2/_thumb_100x100.png" title="Zombie Taxi 2" /></a><a href="http://www.triqui.com/2009/10/23/zombie-taxi-2/" target = "_blank"><strong>Zombie Taxi 2</strong></a>: Half Grand Theft Auto (the fist release), half Carmageddon, you have to rescue the people in the city before they become infected.</p>
<p><strong>What I liked</strong>: the overall experience</p>
<p><strong>Programming difficulty</strong>: Making a really clean and complete game is never easy. <strong>4/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/23/globulos-challenge/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/globulos-challenge_v2/_thumb_100x100.png" title="Globulous Challenge" /></a><a href="http://www.triqui.com/2009/10/23/globulos-challenge/" target = "_blank"><strong>Globulous Challenge</strong></a>: single player version of <a href="http://www.globulos.com/" target ="_blank">Globulos</a> game, features 25 levels you have to complete in just one turn</p>
<p><strong>What I liked</strong>: great strategy game</p>
<p><strong>Programming difficulty</strong>: besides the level design, it&#8217;s a quite easy physics game without gravity <strong>2/5</strong><span id="more-1798"></span></p>
<p><a href="http://www.triqui.com/2009/10/23/a-dralien-day/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/a-dralien-day/_thumb_100x100.jpg" title="A Dralien Day" /></a><a href="http://www.triqui.com/2009/10/23/a-dralien-day/" target = "_blank"><strong>A Dralien Day</strong></a>: Excellent point and click graphic adventure, a must see even if you don&#8217;t like escape games.</p>
<p><strong>What I liked</strong>: really really good graphics</p>
<p><strong>Programming difficulty</strong>: it&#8217;s not just a point and click game, there are some minigames that raise the difficulty <strong>3/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/23/dropple-2/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/dropple-2/_thumb_100x100.jpg" title="Dropple 2" /></a><a href="http://www.triqui.com/2009/10/23/dropple-2/" target = "_blank"><strong>Dropple 2</strong></a>: classic &#8220;collect everything with a ball&#8221; game, with all features you can expect.</p>
<p><strong>What I liked</strong>: I can&#8217;t get enough of these games</p>
<p><strong>Programming difficulty</strong>: different tile types mean different scripting&#8230; <strong>3/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/21/whindy-in-a-colorless-world/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/whindy-in-a-colorless-world/_thumb_100x100.jpg" title="Whindy: in a Colorless World" /></a><a href="http://www.triqui.com/2009/10/21/whindy-in-a-colorless-world/" target = "_blank"><strong>Whindy: in a Colorless World</strong></a>: great platform game with cool graphics and an interesting story&#8230; colors have been stolen and it&#8217;s up to you to bring them again in the world</p>
<p><strong>What I liked</strong>: the graphic style and the gameplay</p>
<p><strong>Programming difficulty</strong>: A complete platform game is never easy to make <strong>4/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/20/speedround/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/speedround/_thumb_100x100.png" title="Speedround" /></a><a href="http://www.triqui.com/2009/10/20/speedround/" target = "_blank"><strong>Speedround</strong></a>: addictive puzzle game, rotate the wheel and place colored gems in order to fill empty slots</p>
<p><strong>What I liked</strong>: the concept</p>
<p><strong>Programming difficulty</strong>: quite easy&#8230; no physics, almost no special effects&#8230; pure gameplay&#8230; <strong>2/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/19/imago-prologue/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/imago-prologue/_thumb_100x100.jpg" title="Imago Prologue" /></a><a href="http://www.triqui.com/2009/10/19/imago-prologue/" target = "_blank"><strong>Imago Prologue</strong></a>: An incredible interactive novel. I mean incredible. Adult contents. I was killed by an hooker</p>
<p><strong>What I liked</strong>: the story. wow.</p>
<p><strong>Programming difficulty</strong>: if&#8230; then&#8230; gotoAndPlay&#8230; <strong>1/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/19/vector-conflict-the-siege/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/vector-conflict-the-siege/_thumb_100x100.png" title="Vector Conflict: the Siege" /></a><a href="http://www.triqui.com/2009/10/19/vector-conflict-the-siege/" target = "_blank"><strong>Vector Conflict: the Siege</strong></a>: Modern Battle Zone (from 1980!!) clone, destroy all enemy vawes and updgrade your base</p>
<p><strong>What I liked</strong>: the graphics, and the overall feeling</p>
<p><strong>Programming difficulty</strong>: for 3D gurus&#8230; <strong>5/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/19/magnets/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/magnets_v2/_thumb_100x100.png" title="Magnets" /></a><a href="http://www.triqui.com/2009/10/19/magnets/" target = "_blank"><strong>Magnets</strong></a>: Puzzle game featuring magnetism to bring a ball from &#8220;A spot&#8221; to &#8220;B spot&#8221;</p>
<p><strong>What I liked</strong>: the idea</p>
<p><strong>Programming difficulty</strong>: I don&#8217;t know that much about magnetism but I think with the right formula it shouldn&#8217;t be that hard <strong>2/5</strong></p>
<p><a href="http://www.triqui.com/2009/10/18/assembler-4/" target = "_blank"><img class = "imgleft" alt="" src="http://thumbs.mochiads.com/c/g/assembler-4/_thumb_100x100.png" title="Assembler 4" /></a><a href="http://www.triqui.com/2009/10/18/assembler-4/" target = "_blank"><strong>Assembler 4</strong></a>: Place all crates to their right places in this physics game</p>
<p><strong>What I liked</strong>: Level design</p>
<p><strong>Programming difficulty</strong>: just some Box2D drag&#8217;n drop <strong>2/5</strong></p>
<p>See you next week</p>
<img src="http://feeds.feedburner.com/~r/EmanueleFeronato/~4/ZG0P6va4BFs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/10/25/triquis-picks-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.emanueleferonato.com/2009/10/25/triquis-picks-2/</feedburner:origLink></item>
	</channel>
</rss>
