<?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>Ben Snider &#187; Front Page</title>
	<atom:link href="http://www.bensnider.com/category/front-page/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bensnider.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 05 May 2010 16:33:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Copying a Flash MovieClip, or The Flash Holy Grail</title>
		<link>http://www.bensnider.com/2009/05/15/copying-a-flash-movieclip-or-the-flash-holy-grail/</link>
		<comments>http://www.bensnider.com/2009/05/15/copying-a-flash-movieclip-or-the-flash-holy-grail/#comments</comments>
		<pubDate>Fri, 15 May 2009 23:41:31 +0000</pubDate>
		<dc:creator>BenSnider</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Front Page]]></category>

		<guid isPermaLink="false">http://www.bensnider.com/?p=65</guid>
		<description><![CDATA[Ran into a nice solution for copying arbitrary MovieClips at runtime today. I am designing a spot the difference game akin to 6 Differences with the requirement that, upon finding a difference, the scene should go to the &#8220;correct&#8221; state depending on which difference was defined as master, among a few other criterion. This required [...]]]></description>
			<content:encoded><![CDATA[<p>Ran into a nice solution for copying arbitrary MovieClips at runtime today. I am designing a spot the difference game akin to <a href="http://www.kongregate.com/games/Ivory/6-differences">6 Differences</a> with the requirement that, upon finding a difference, the scene should go to the &#8220;correct&#8221; state depending on which difference was defined as master, among a few other criterion. This required that I somehow duplicate, as much as is possible, the state of the &#8220;master&#8221; difference, when appropriate.</p>
<p>At any rate, the solution comes from <a href="http://www.dannyburbol.com/2009/01/movieclip-clone-flash-as3/">Danny Burbol&#8217;s blog</a>, which apparently came from a <a href="http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/Q_22684629.html">Experts Exchange thread</a> (damn people charging for information). I modified the solution a bit to fit my needs, but not by a whole lot. Sometimes I only need to copy the instance and I can reconstitute the MovieClip from there but other times I will need to get the whole shebang. It&#8217;s pretty handy in general. So my version follows (as a bonus I include my handy-dandy clearAllChildren function):</p>
<pre class="prettyprint">
package com.bmm.utils {
  import flash.display.DisplayObject;
  import flash.display.DisplayObjectContainer;
  import flash.geom.Rectangle;

  /**
   * ...
   * @author BenS
   */
  public class UIUtils {

    public static function clearAllChildren(c:DisplayObjectContainer):void {
      if (c == null || c.numChildren == 0) return;

      var i:int = 0, n:int = c.numChildren;
      for (i = 0; i < n; i++) {
        c.removeChildAt(0);
      }
    }

    public static function simpleDisplayObjectClone(source:DisplayObject):DisplayObject {
      var cc:Class = Object(source).constructor;
      return new cc();
    }

    public static function displayObjectClone(source:DisplayObject):DisplayObject {
      var copy:DisplayObject = UIUtils.simpleDisplayObjectClone(source);

      copy.transform = source.transform;
      copy.filters = source.filters;
      copy.cacheAsBitmap = source.cacheAsBitmap;
      copy.opaqueBackground = source.opaqueBackground;
      if (source.scale9Grid) {
        var r:Rectangle = source.scale9Grid;
        copy.scale9Grid = r;
      }

      return copy;
    }
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bensnider.com/2009/05/15/copying-a-flash-movieclip-or-the-flash-holy-grail/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Python Lies</title>
		<link>http://www.bensnider.com/2008/02/17/python-lies/</link>
		<comments>http://www.bensnider.com/2008/02/17/python-lies/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 23:13:01 +0000</pubDate>
		<dc:creator>BenSnider</dc:creator>
				<category><![CDATA[Front Page]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.bensnider.com/2008/02/17/python-lies/</guid>
		<description><![CDATA[This is probably a documented issue, but I think it deserves another mention. Python lies, its the truth. Well, as much as an interpreter can lie. Say we want to do some math in Python. Say we want to raise large numbers to large numbers. Say those numbers are 324 and 324. Then we would [...]]]></description>
			<content:encoded><![CDATA[<p>This is probably a documented issue, but I think it deserves another mention. Python lies, its the truth. Well, as much as an interpreter can lie.</p>
<p>Say we want to do some math in Python. Say we want to raise large numbers to large numbers. Say those numbers are 324 and 324. Then we would do something like:</p>
<pre class="prettyprint">&lt;&lt;&lt; 324**324</pre>
<p>and see all the pretty numbers spew out from the interpreter. How do we know if this is right or wrong though? Say we use long doubles in C++ to determine the results of this same operation. Then we would do something like:</p>
<pre class="prettyprint">
long double k = 324;
for (int i=0; i&lt;324; ++i) {
    k *= k
}
std::cout &lt;&lt; "324^324 = " &lt;&lt; k &lt;&lt; "n";</pre>
<p>But alas, the output is &#8220;inf&#8221;, so we check the largest long double our compiler and machine can represent and find that it is roughly equal to 1.2e+4932. We then check in python if this number is greater than 324^324 by doing something like:</p>
<pre class="prettyprint">&gt;&gt;&gt;&gt; (12**4932) &gt; (324**324)
True</pre>
<p>However, this contradicts the fact that C++ could not represent 324^324, so Python must be lying. Indeed we check the largest power of 324 we can represent in C++ long doubles, and it turns out to be 11. Thus Python lies.</p>
<p>What does this mean. Don&#8217;t rely on Python for numeric accuracy without checking its results.</p>
<p><strong>Update</strong>: This post is probably wrong, but I don&#8217;t like deleting things. So refer to Tyler&#8217;s comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bensnider.com/2008/02/17/python-lies/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
