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

<channel>
	<title>Mike R :: R ekim &#187; flash</title>
	<atom:link href="http://www.rekim.com/topics/tech/flash/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rekim.com</link>
	<description>Mike Robinson</description>
	<lastBuildDate>Sat, 27 Jan 2024 18:04:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Gorillaz Submatronic Game</title>
		<link>https://www.rekim.com/2011/02/11/gorillaz-submatronic-game/</link>
		<comments>https://www.rekim.com/2011/02/11/gorillaz-submatronic-game/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 18:23:33 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[box2d]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[gorillaz]]></category>
		<category><![CDATA[submatronic]]></category>
		<category><![CDATA[wck]]></category>

		<guid isPermaLink="false">http://www.rekim.com/?p=70</guid>
		<description><![CDATA[A few months ago we stuck a new game up on Gorillaz.com that I think is great! It&#8217;s built using the the box2d WCK found here http://www.sideroller.com/wck/ that is an awesome system. It&#8217;s got a c++ alchemy version of box2d &#8230; <a href="https://www.rekim.com/2011/02/11/gorillaz-submatronic-game/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A few months ago we stuck a new game up on Gorillaz.com that I think is great!</p>
<p style="text-align: center;"><a style="text-align: center;" href="http://gorillaz.com/g-player/games/submatronic"><img class="aligncenter" title="Gorillaz Submatronic" src="http://gorillaz.com/images/xmas/xmas-3rd-submatronic.jpg" alt="Gorillaz Submatronic" width="576" height="385" /></a></p>
<p>It&#8217;s built using the the box2d WCK found here <a href="http://www.sideroller.com/wck/">http://www.sideroller.com/wck/</a> that is an awesome system. It&#8217;s got a c++ alchemy version of box2d in it so it&#8217;s really fast and the world creator kit lets you drag items around in the IDE and even use the timeline to animate bodies.</p>
<p>For this game we created a proxy system that let us layout the levels graphically on stage in their own swfs. This was then replaced with the physics objects from the base swf once they were loaded and added to the stage. After the initial load each level load was just a few KBs, quick to compile and behaviours could be changed for all the levels by editing the base.</p>
<p>All the crazy physics stuff was topped off with some really great graphics from <a title="Adam Gale" href="http://www.adamgale.net/">Adam Gale</a>. The last level of the story mode where you&#8217;re floating round inside a whale is brilliant!</p>
<p><a href="http://gorillaz.com/g-player/games/submatronic">http://gorillaz.com/g-player/games/submatronic</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.rekim.com/2011/02/11/gorillaz-submatronic-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Google Analytics Lite</title>
		<link>https://www.rekim.com/2010/07/27/flash-google-analytics-lite/</link>
		<comments>https://www.rekim.com/2010/07/27/flash-google-analytics-lite/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 22:37:30 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.rekim.com/?p=64</guid>
		<description><![CDATA[I&#8217;ve been using Google analytics to track events and page views. It works really well and using the events for levels and play length can be extremely helpful. The big problem though is the file size. An empty swf compiled &#8230; <a href="https://www.rekim.com/2010/07/27/flash-google-analytics-lite/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using Google analytics to track events and page views. It works really well and using the events for levels and play length can be extremely helpful. The big problem though is the file size. An empty swf compiled in flashdevelop with just my google analytics class comes to nearly 70k.</p>
<p>I took a look around for anyone who&#8217;d made a light weight version and couldn&#8217;t find any so in the end I had a go myself.</p>
<p>The obvious place to start seemed to be the debug code. It&#8217;s very woven into the main code, I think it would be extremely useful if they provide a version without the debug system for final versions.</p>
<p>Anyway, here is a quick guide on how to quickly strip a few kbs.</p>
<p><strong>Quick Start</strong></p>
<p>Download the latest version over svn from here <a href="http://code.google.com/p/gaforflash/source/checkout">http://code.google.com/p/gaforflash/source/checkout</a></p>
<p>If you want a quick start I have a quick Tracking class, I haven&#8217;t got the original to hand but I recreated it off my the top of my head.<a href="/wp-content/uploads/Tracking.as"> download here </a>. You use it like so.</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900; font-style: italic;">//Setup the on stage display object required for GA and the account</span><br />
Tracking<span style="color: #000066; font-weight: bold;">.</span>GAaccountID = <span style="color: #990000;">&quot;GAXXXXX-XXXX&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
Tracking<span style="color: #000066; font-weight: bold;">.</span>root_display_object = <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
Tracking<span style="color: #000066; font-weight: bold;">.</span>trackPage<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;/link/link&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
Tracking<span style="color: #000066; font-weight: bold;">.</span>trackEvent<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Game&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;start level&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;game title&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></div>
<p><strong>Start Stripping</strong></p>
<p>com.google.analytics.debug.DebugConfiguration.as seems be the main file we can start with.</p>
<p>You want to strip out ever mention of  layout:ILayout. First comment out the</p>
<p>public var layout:ILayout;</p>
<p>then head down and comment out any if containing layout. You can clear the whole contents of any if with it like so:</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> _initializeVisual<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #3f5fbf;">/*if( layout )<br />
{<br />
layout.init();<br />
_visualInitialized = true;<br />
}*/</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>Once you&#8217;ve cleared out any ifs mentioning layout there&#8217;s only one more mention of it inside  com.google.analytics.GATracker.as. Remove the import of layout and in the _factory() function comment out the contents of the if( visualDebug ){<br />
Compiling that lops the file down by 13KB<br />
You can carry on hacking away. Staying in GATracker.as I found that as I was only using the AS3 mode so I removed the case and the factory function mentioned in the following switch</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #3f5fbf;">/*case TrackerMode.BRIDGE :<br />
{<br />
activeTracker = _bridgeFactory();<br />
break;<br />
}*/</span></div></div>
<p>after deleting the _bridgeFactory function I removed the import of Bridge as well this takes off a few more KB.<br />
There&#8217;s plenty more that you can play with but the above is a 2 minute job that can get about 20KB off you&#8217;re project.<br />
OK Bye</p>
]]></content:encoded>
			<wfw:commentRss>https://www.rekim.com/2010/07/27/flash-google-analytics-lite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>connecting to a .htaccess passworded server without access</title>
		<link>https://www.rekim.com/2009/12/28/connecting-to-a-htaccess-passworded-server-without-access/</link>
		<comments>https://www.rekim.com/2009/12/28/connecting-to-a-htaccess-passworded-server-without-access/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 18:34:24 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[authorisation]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[proxy-authorization]]></category>

		<guid isPermaLink="false">http://www.rekim.com/?p=60</guid>
		<description><![CDATA[I wanted to do some work over christmas on a site that uses an amfphp connection to get data. Where I was going didn&#8217;t have a fixed IP so we opened the port access up and put a username and &#8230; <a href="https://www.rekim.com/2009/12/28/connecting-to-a-htaccess-passworded-server-without-access/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I wanted to do some work over christmas on a site that uses an amfphp connection to get data. Where I was going didn&#8217;t have a fixed IP so we opened the port access up and put a username and password on it using .htaccess.</p>
<p>This was great until I realised that I needed to authorise the connection before I could use amfphp and flash wasn&#8217;t prompting for it or allowing me to use the proxy-authorization header I needed without access to the crossdomain.xml. One easy way of sorting it is to open the swf in a browser, go to a static page that prompts the login then load the flash but this was too faffy and I wanted the debugging from flashdevelop or the flash IDE.</p>
<p>Anyway heres a quick bodge way of getting it temporarily working in the flash IDE and Flash Develop</p>
<p>In flash changing the publishing to AIR meant that it now pops up login and it all works fine. (I had to remove a few allowDomain lines out ).</p>
<p>In Flash Develop set the &#8220;project settings&#8221; &#8211; &#8220;Test Movie&#8221; to &#8220;play in new tab&#8221;.<br />
I can&#8217;t remember if this prompts automatically but if not the 401 error message that appears in the output window shows the url it was trying to connect to and clicking it will prompt you for a login.</p>
<p>Any easy options I&#8217;ve missed?</p>
]]></content:encoded>
			<wfw:commentRss>https://www.rekim.com/2009/12/28/connecting-to-a-htaccess-passworded-server-without-access/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>graphics.curveTo through point</title>
		<link>https://www.rekim.com/2009/11/15/graphics-curveto-through-point/</link>
		<comments>https://www.rekim.com/2009/11/15/graphics-curveto-through-point/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 21:21:02 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.rekim.com/?p=38</guid>
		<description><![CDATA[When I was doing the rope demo a few posts down I had to use the graphics.curveTo, but get it curve through a point instead of using the point as a control. I found a function a while back that &#8230; <a href="https://www.rekim.com/2009/11/15/graphics-curveto-through-point/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I was doing the rope demo a few posts down I had to use the graphics.curveTo, but get it curve through a point instead of using the point as a control. I found a function a while back that I&#8217;ll try to source so I take no credit for it, but this is my revision of if.<br />
<span id="more-38"></span></p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339966; font-weight: bold;">function</span> curveThroughPoint<span style="color: #000000;">&#40;</span>$start<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000066; font-weight: bold;">,</span>$mid<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000066; font-weight: bold;">,</span> $end<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000066; font-weight: bold;">*</span> $mid<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">0.5</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span> $start<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> $end<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000066; font-weight: bold;">*</span> $mid<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">0.5</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span> $start<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span> $end<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>Then you can use something like</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> startPos<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> midPos<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">200</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> endPos<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">300</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
midPos = curveThroughPoint<span style="color: #000000;">&#40;</span> startPos<span style="color: #000066; font-weight: bold;">,</span> midPos<span style="color: #000066; font-weight: bold;">,</span> endPos <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span>0x000000 <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span> startPos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> startPos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">curveTo</span><span style="color: #000000;">&#40;</span> midPos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> midPos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> endPos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> endPos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></div>
<p>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="275" height="200">
      <param name="movie" value="http://www.rekim.com/wp-content/uploads/2009/11/curveThroughPoint.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.rekim.com/wp-content/uploads/2009/11/curveThroughPoint.swf" width="275" height="200">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
<br />
<a href="http://www.rekim.com/2009/11/06/quickbox2d-string-and-balls/">here&#8217;s me quickbox2d rope example that used it</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.rekim.com/2009/11/15/graphics-curveto-through-point/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>facebook style post dates</title>
		<link>https://www.rekim.com/2009/11/14/facebook-style-post-dates/</link>
		<comments>https://www.rekim.com/2009/11/14/facebook-style-post-dates/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 18:24:55 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.rekim.com/?p=27</guid>
		<description><![CDATA[A very quick bodge function for returning a nice post time. Returns stuff like &#8220;2 seconds ago&#8221;,&#8221;23 minutes&#8221;, &#8220;about an hour&#8221;, &#8220;3 hours ago&#8221;,&#8221;yesterday at 3:00pm&#8221;,&#8221;wed at 3:00pm&#8221;, &#8220;Nov 2 at 3:00pm&#8221; Haven&#8217;t tested it much so might want a &#8230; <a href="https://www.rekim.com/2009/11/14/facebook-style-post-dates/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A very quick bodge function for returning a nice post time.<br />
Returns stuff like &#8220;2 seconds ago&#8221;,&#8221;23 minutes&#8221;, &#8220;about an hour&#8221;, &#8220;3 hours ago&#8221;,&#8221;yesterday at 3:00pm&#8221;,&#8221;wed at 3:00pm&#8221;, &#8220;Nov 2 at 3:00pm&#8221;</p>
<p>Haven&#8217;t tested it much so might want a tweak and I haven&#8217;t added year as I don&#8217;t really need it. Leave the second parameter out to use the system date as current.</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span> postTime<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=date%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:date.html"><span style="color: #004993;">Date</span></a><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;18:07:12 2009/11/14&quot;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #339966; font-weight: bold;">function</span> postTime<span style="color: #000000;">&#40;</span> dateToCheck<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=date%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:date.html"><span style="color: #004993;">Date</span></a><span style="color: #000066; font-weight: bold;">,</span> currentDate<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=date%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:date.html"><span style="color: #004993;">Date</span></a> = <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> currentDate == <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; currentDate = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=date%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:date.html"><span style="color: #004993;">Date</span></a><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> day_name<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;Sun&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Mon&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Tues&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Wed&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Thurs&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Fri&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Sat&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> month_name<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;Jan&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Feb&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Mar&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Apr&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;May&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Jun&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Jul&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Aug&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Sept&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Oct&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Nov&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Dec&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> theTime<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> day_dif<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">seconds</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000;">&#40;</span> currentDate<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">valueOf</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> dateToCheck<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">valueOf</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">seconds</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">60</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">seconds</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; seconds ago &quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">seconds</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">3540</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">seconds</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">60</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; minute&quot;</span><span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span> seconds<span style="color: #000066; font-weight: bold;">&lt;</span><span style="color: #000000; font-weight:bold;">120</span><span style="color: #000066; font-weight: bold;">?</span><span style="color: #990000;">&quot;&quot;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;s&quot;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; ago &quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">seconds</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">6500</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #990000;">&quot;About an hour ago&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">seconds</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">86400</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000;">&#40;</span> currentDate<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">day</span> == dateToCheck<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">day</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">seconds</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">3600</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; hours ago&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; theTime = <span style="color: #000000;">&#40;</span> dateToCheck<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">hours</span> <span style="color: #000066; font-weight: bold;">%</span> <span style="color: #000000; font-weight:bold;">12</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;:&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> dateToCheck<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">minutes</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span> dateToCheck<span style="color: #000066; font-weight: bold;">.</span>hours<span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight:bold;">12</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">?</span><span style="color: #990000;">&quot;pm&quot;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;am&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dateToCheck<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">hours</span> = currentDate<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">hours</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; day_dif = <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> currentDate<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">valueOf</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> dateToCheck<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">valueOf</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">86400000</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> day_dif == <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #990000;">&quot;Yesterday at &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> theTime<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> day_dif <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">7</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> day_name<span style="color: #000000;">&#91;</span> dateToCheck<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">day</span> <span style="color: #000000;">&#93;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; at &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> theTime<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> month_name<span style="color: #000000;">&#91;</span> dateToCheck<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">month</span> <span style="color: #000000;">&#93;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> dateToCheck<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">date</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot; at &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> theTime<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>https://www.rekim.com/2009/11/14/facebook-style-post-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chaos Pendulum</title>
		<link>https://www.rekim.com/2009/11/07/chaos-pendulum/</link>
		<comments>https://www.rekim.com/2009/11/07/chaos-pendulum/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 13:51:58 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[experiments]]></category>

		<guid isPermaLink="false">http://www.rekim.com/?p=21</guid>
		<description><![CDATA[We saw a program that had a double pendulum called the chaos pendulum and my girlfriend said I should try and make it, so I had a quick play in quickbox2d. It was being used as an example of chaotic &#8230; <a href="https://www.rekim.com/2009/11/07/chaos-pendulum/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We saw a program that had a double pendulum called the chaos pendulum and my girlfriend said I should try and make it, so I had a quick play in quickbox2d. It was being used as an example of chaotic looking movement that wasn&#8217;t random. Here&#8217;s a real one.</p>
<p><object width="425" height="350" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/Whvl6CikDxA" /><embed width="425" height="350" type="application/x-shockwave-flash" src="http://www.youtube.com/v/Whvl6CikDxA" /></object></p>
<p>and here&#8217;s the flash on, it&#8217;s not as good but box2d does an interesting job.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_1" width="450" height="350">
      <param name="movie" value="http://www.rekim.com/wp-content/uploads/2009/11/chaos_pendulum_2.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.rekim.com/wp-content/uploads/2009/11/chaos_pendulum_2.swf" width="450" height="350">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p><span id="more-21"></span></p>
<p>let&#8217;s test putting some code on here..  then you need to get <a href="http://actionsnippet.com/?page_id=1391">quickbox2d</a>&#8230;</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>actionsnippet<span style="color: #000066; font-weight: bold;">.</span>qbox<span style="color: #000066; font-weight: bold;">.*;</span><br />
<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">frameRate</span> = <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> sim<span style="color: #000066; font-weight: bold;">:</span>QuickBox2D = <span style="color: #0033ff; font-weight: bold;">new</span> QuickBox2D<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> $x<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">9</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> $y<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">4</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> $length<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">5</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> $radius<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0.5</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> pin_to<span style="color: #000066; font-weight: bold;">:</span>QuickObject = sim<span style="color: #000066; font-weight: bold;">.</span>addBox<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span>$y<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.25</span><span style="color: #000066; font-weight: bold;">,</span>density<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> maskBits<span style="color: #000066; font-weight: bold;">:</span>0x0008 <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> top_pendulum<span style="color: #000066; font-weight: bold;">:</span>QuickObject = sim<span style="color: #000066; font-weight: bold;">.</span>addBox<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span>$y<span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span>$length <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">:</span>$length<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1.5</span><span style="color: #000066; font-weight: bold;">,</span>friction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span>restitution<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> bottom_pendulum<span style="color: #000066; font-weight: bold;">:</span>QuickObject = sim<span style="color: #000066; font-weight: bold;">.</span>addBox<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span>$y <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span> $length <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">1.3</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">:</span>$length<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.75</span><span style="color: #000066; font-weight: bold;">,</span>friction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span>restitution<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//SET UP JOINTS</span><br />
sim<span style="color: #000066; font-weight: bold;">.</span>addJoint<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;revolute&quot;</span><span style="color: #000066; font-weight: bold;">,</span>a<span style="color: #000066; font-weight: bold;">:</span>pin_to<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">:</span>top_pendulum<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">,</span>collideConnected<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> x1<span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> y1<span style="color: #000066; font-weight: bold;">:</span>$y<span style="color: #000066; font-weight: bold;">,</span> x2<span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> y2<span style="color: #000066; font-weight: bold;">:</span>$y <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
sim<span style="color: #000066; font-weight: bold;">.</span>addJoint<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;revolute&quot;</span><span style="color: #000066; font-weight: bold;">,</span>a<span style="color: #000066; font-weight: bold;">:</span>top_pendulum<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">:</span>bottom_pendulum<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">,</span>collideConnected<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> x1<span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> y1<span style="color: #000066; font-weight: bold;">:</span>$y<span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span> $length <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.9</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> x2<span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> y2<span style="color: #000066; font-weight: bold;">:</span>$y<span style="color: #000066; font-weight: bold;">+</span>$length<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.25</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
sim<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
sim<span style="color: #000066; font-weight: bold;">.</span>mouseDrag<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//ADD RANDOM ANGULAR VELOCITY ON CLICK</span><br />
<span style="color: #009900; font-style: italic;">//JUST SETTING THE bottom_pendulum SEEMS TO WORK</span><br />
<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> clicked <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #339966; font-weight: bold;">function</span> clicked<span style="color: #000000;">&#40;</span> e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
bottom_pendulum<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">.</span>SetAngularVelocity<span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">10000</span><span style="color: #000066; font-weight: bold;">-</span><a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">20000</span> <span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>https://www.rekim.com/2009/11/07/chaos-pendulum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quickbox2d string and balls</title>
		<link>https://www.rekim.com/2009/11/06/quickbox2d-string-and-balls/</link>
		<comments>https://www.rekim.com/2009/11/06/quickbox2d-string-and-balls/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 00:15:43 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[experiments]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.rekim.com/?p=8</guid>
		<description><![CDATA[Right my first geeky quick flash experiment&#8230;&#8230; Skip past the text and take a look at the fun. A few games I&#8217;ve been working on at the mo have required some 2d physics so I&#8217;ve been looking at box2d again. &#8230; <a href="https://www.rekim.com/2009/11/06/quickbox2d-string-and-balls/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Right my first geeky quick flash experiment&#8230;&#8230; Skip past the text and take a look at the fun.</p>
<p>A few games I&#8217;ve been working on at the mo have required some 2d physics so I&#8217;ve been looking at box2d again. The last thing I did with it was <a title="gorillaz bananaz cannon" href="http://www.bananazfilm.com/games/bananacannon/">&#8220;banana cannon&#8221;</a> balancing game for Gorillaz Bananaz. Since then <a title="actionsnippet" href="http://www.actionsnippet.org">actionsnippet.org</a> has packaged up box2d into <a title="quickbox2d" href="http://actionsnippet.com/?page_id=1391">quickbox2d</a> making it &#8220;quick&#8221;. It&#8217;s worth a look.</p>
<p>Anyway one of the things needed was a nice looking rope/wire effect connecting 2 objects that would allow them to move freely when the rope wasn&#8217;t tort. I couldn&#8217;t find a single joint that didn&#8217;t affect the rotation of the other object while moving around. I&#8217;m sure there&#8217;s probably a better way, but I managed to achieve the effect by creating a an extra hidden object like a knee inbetween the 2 and applying a distance joint from the knee to each object. Then to cheat a nice bendy/rubbery rope look I drew a line using curveTo going from one object to the other bending towards the knee. Take a look below.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_2" width="500" height="370">
      <param name="movie" value="http://www.rekim.com/wp-content/uploads/2009/11/swings.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.rekim.com/wp-content/uploads/2009/11/swings.swf" width="500" height="370">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>And behind the scenes</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_3" width="275" height="200">
      <param name="movie" value="http://www.rekim.com/wp-content/uploads/2009/11/swings_debug1.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.rekim.com/wp-content/uploads/2009/11/swings_debug1.swf" width="275" height="200">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>UPDATE:<br />
I&#8217;ve added a post about calculating a point to make curveTo curveThrough a point. It&#8217;s how the string curves towards the knee.<br />
<a href="http://www.rekim.com/2009/11/15/graphics-curveto-through-point/">graphics-curveto-through-point</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.rekim.com/2009/11/06/quickbox2d-string-and-balls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
