<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>explorers&#039; club</title>
	<atom:link href="http://jwopitz.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jwopitz.wordpress.com</link>
	<description>explorations in dev, science, sci-fi, games, and other fun stuff!</description>
	<lastBuildDate>Wed, 12 Jun 2013 16:37:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jwopitz.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>explorers&#039; club</title>
		<link>http://jwopitz.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jwopitz.wordpress.com/osd.xml" title="explorers&#039; club" />
	<atom:link rel='hub' href='http://jwopitz.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Scrolling, iFrames &amp; Facebook Apps</title>
		<link>http://jwopitz.wordpress.com/2013/04/30/scrolling-iframes-facebook-apps/</link>
		<comments>http://jwopitz.wordpress.com/2013/04/30/scrolling-iframes-facebook-apps/#comments</comments>
		<pubDate>Tue, 30 Apr 2013 15:35:19 +0000</pubDate>
		<dc:creator>jwopitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[facebook app]]></category>
		<category><![CDATA[facebook canvas]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[onmousewheel]]></category>
		<category><![CDATA[onScroll]]></category>
		<category><![CDATA[preventDefault]]></category>
		<category><![CDATA[scrolling]]></category>
		<category><![CDATA[stopPropagation]]></category>

		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=717</guid>
		<description><![CDATA[THE PROBLEM I have a Flash SWF being loaded into a PHP page that then is being loaded into a Facebook canvas. The FB page has content in the right side ad area that creates a vertical scroll bar regardless &#8230; <a href="http://jwopitz.wordpress.com/2013/04/30/scrolling-iframes-facebook-apps/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=717&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>THE PROBLEM</h3>
<p>I have a Flash SWF being loaded into a PHP page that then is being loaded into a Facebook canvas. The FB page has content in the right side ad area that creates a vertical scroll bar regardless of the height of my game content. My game&#8217;s canvas has a fluid height in order to fully fill the content area of the canvas</p>
<p>There is a zoom feature in my game that is triggered by the mouse wheel.</p>
<p>When using the mouse wheel (to zoom in my game), this is also getting picked up by the browser to scroll the content. So I&#8217;m getting a simultaneous zoom/scroll effect going on which is undesirable to say the least.</p>
<p>original Stackoverflow post - <a href="http://stackoverflow.com/questions/16302789/understanding-javascript-scrolling-iframes">http://stackoverflow.com/questions/16302789/understanding-javascript-scrolling-iframes</a></p>
<h3>THE SOLUTION (I THINK)</h3>
<p>If  the FB canvas content has no overflow, then it will not trigger scroll events via the mouse.  It will however trigger mouse wheel events, which are necessary for triggering the scroll events via the mouse.  By cancelling and stopping the propagation of the mousewheel event, you are stopping that event from reaching into the non-iFrame content owned by Facebook.</p>
<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;script type="text/javascript"&gt;
        function init () 
        {
        }

    &lt;/script&gt;
&lt;/head&gt;

&lt;body onload="init()"&gt;
    &lt;script type="text/javascript"&gt;

        function onScrollHandler(event)
        {
            event.preventDefault();
            event.stopPropagation();

            //alert("scrolling");       
        }

    &lt;/script&gt;

    &lt;div id="content" onmousewheel="onScrollHandler(event)" onclick="alert('click')" style="position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px; background-color:#b0c4de;"&gt;
        content area
    &lt;/div&gt;
&lt;/body&gt;</code></pre>
<p>If you&#8217;d like to test this yourself, set up a FB app and use this as your app&#8217;s content HTML.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jwopitz.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jwopitz.wordpress.com/717/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=717&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jwopitz.wordpress.com/2013/04/30/scrolling-iframes-facebook-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/290aadf0da43aaaf3cf84934c9c42bf5?s=96&#38;d=http%3A%2F%2F2.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jwopitz</media:title>
		</media:content>
	</item>
		<item>
		<title>Note to Self: Phone Number to String formatting</title>
		<link>http://jwopitz.wordpress.com/2012/11/08/note-to-self-phone-number-to-string-formatting/</link>
		<comments>http://jwopitz.wordpress.com/2012/11/08/note-to-self-phone-number-to-string-formatting/#comments</comments>
		<pubDate>Thu, 08 Nov 2012 17:05:09 +0000</pubDate>
		<dc:creator>jwopitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=706</guid>
		<description><![CDATA[Yep&#8230; still doing as3 and flex. So the issue is this: The current database table that stores a phone number basically has a column for area code, a column for the phone number prefix and then a column for the &#8230; <a href="http://jwopitz.wordpress.com/2012/11/08/note-to-self-phone-number-to-string-formatting/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=706&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Yep&#8230; still doing as3 and flex.</p>
<p>So the issue is this: The current database table that stores a phone number basically has a column for area code, a column for the phone number prefix and then a column for the suffix. Each has a 5 digit limit. This is an enterprise-wide table scheme for storing their phone numbers, so making a db change is unlikely to happen.</p>
<p>As for making the service modification to send the client a string&#8230;. well that&#8217;s a topic for another post.  The short of it is that I am parsing the above 3 fields coming in and aggregating them into a string value.  Here&#8217;s how (since the logic is kinda wonky).</p>
<pre>           
[Deprecated]
public var phArea:int;

[Deprecated]
public var ph1:int;

[Deprecated]
public var ph2:int;

[Transient]
[Bindable]
public function get phoneNoString():String
{
	var s0:String = phArea &gt; 0 ? phArea.toString() : "";
	var s1:String = ph1 &gt; 0 ? ph1.toString() : "";
	var s2:String = ph2 &gt; 0 ? ph2.toString() : "";

	return s0 + s1 + s2;
}

public function set phoneNoString( value:String ):void
{
        //remove any non-digit characters, e.g. (###) ###-####
        var s:String = value ? value.replace( /[\D]/g, "" ) : "";

	phArea = int( s.slice( 0, Math.min( 3, s.length )));
	ph1 = s.length &gt; 3 ? int( s.slice( 3, Math.min( 6, s.length ))) : 0;
	ph2 = s.length &gt; 6 ? int( s.slice( 6, s.length )) : 0;
}</pre>
<p>There may be more efficient ways to achieve this (say via RegExp) but this was my first quick and dirty attempt to fix this irritating requirement.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jwopitz.wordpress.com/706/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jwopitz.wordpress.com/706/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=706&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jwopitz.wordpress.com/2012/11/08/note-to-self-phone-number-to-string-formatting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/290aadf0da43aaaf3cf84934c9c42bf5?s=96&#38;d=http%3A%2F%2F2.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jwopitz</media:title>
		</media:content>
	</item>
		<item>
		<title>Fun @ the DR&#8217;s Office</title>
		<link>http://jwopitz.wordpress.com/2012/04/14/fun-the-drs-office/</link>
		<comments>http://jwopitz.wordpress.com/2012/04/14/fun-the-drs-office/#comments</comments>
		<pubDate>Sat, 14 Apr 2012 19:40:27 +0000</pubDate>
		<dc:creator>jwopitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=639</guid>
		<description><![CDATA[I thought i would show you my new right bionic arm:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=639&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I thought i would show you my new right bionic arm:</p>
<p><a href="http://jwopitz.files.wordpress.com/2012/04/0413121030.jpeg"><img class="size-full wp-image" src="http://jwopitz.files.wordpress.com/2012/04/0413121030.jpeg?w=1014" alt="Image" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jwopitz.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jwopitz.wordpress.com/639/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=639&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jwopitz.wordpress.com/2012/04/14/fun-the-drs-office/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/290aadf0da43aaaf3cf84934c9c42bf5?s=96&#38;d=http%3A%2F%2F2.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jwopitz</media:title>
		</media:content>

		<media:content url="http://jwopitz.files.wordpress.com/2012/04/0413121030.jpeg?w=1014" medium="image">
			<media:title type="html">Image</media:title>
		</media:content>
	</item>
		<item>
		<title>Note to Self: Spark State Exclusions</title>
		<link>http://jwopitz.wordpress.com/2012/03/26/note-to-self-spark-state-exclusions/</link>
		<comments>http://jwopitz.wordpress.com/2012/03/26/note-to-self-spark-state-exclusions/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 16:25:17 +0000</pubDate>
		<dc:creator>jwopitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=628</guid>
		<description><![CDATA[[Note to Self] In some cases you may develop a particular UX to have nested state exclusion such as: &#60;s:Group excludeFrom="default"&#62; &#60;s:Group excludeFrom="stateB"/&#62; &#60;/s:Group&#62; Problem You will encounter this Compile-Time Error: Component cannot be realized within state &#8216;default&#8217; because an &#8230; <a href="http://jwopitz.wordpress.com/2012/03/26/note-to-self-spark-state-exclusions/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=628&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h1>[Note to Self]</h1>
<p>In some cases you may develop a particular UX to have nested state exclusion such as:</p>
<pre>&lt;s:Group excludeFrom="default"&gt;
    &lt;s:Group excludeFrom="stateB"/&gt;
&lt;/s:Group&gt;</pre>
<h1>Problem</h1>
<p>You will encounter this Compile-Time Error:</p>
<p style="padding-left:30px;"><span style="color:#ff0000;">Component cannot be realized within state &#8216;default&#8217; because an ancestor is excluded from &#8216;default&#8217;.</span></p>
<p>The intent being that the outer group is excluded from only one state, however you also want to apply additional exclusions to that group&#8217;s children, in this case, the child group ALSO being excluded from &#8220;stateB&#8221;.  To recap the child group is to be exclude from both &#8220;default&#8221; and &#8220;stateB&#8221;.</p>
<h1>Solution</h1>
<p>You must explicitly define all state exclusions to the nested objects like so:</p>
<pre>&lt;s:Group excludeFrom="default"&gt;
    &lt;s:Group excludeFrom="<span style="color:#ff0000;">default</span>, stateB"/&gt;
&lt;/s:Group&gt;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jwopitz.wordpress.com/628/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jwopitz.wordpress.com/628/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=628&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jwopitz.wordpress.com/2012/03/26/note-to-self-spark-state-exclusions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/290aadf0da43aaaf3cf84934c9c42bf5?s=96&#38;d=http%3A%2F%2F2.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jwopitz</media:title>
		</media:content>
	</item>
		<item>
		<title>using bitflags and bitwise math</title>
		<link>http://jwopitz.wordpress.com/2012/02/13/using-bitflags-and-bitwise-math/</link>
		<comments>http://jwopitz.wordpress.com/2012/02/13/using-bitflags-and-bitwise-math/#comments</comments>
		<pubDate>Mon, 13 Feb 2012 18:30:30 +0000</pubDate>
		<dc:creator>jwopitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=614</guid>
		<description><![CDATA[[note to self] given the following: const FLAG_A:uint = 1 &#60;&#60; 0; // dec = 1, bit = 0001 const FLAG_B:uint = 1 &#60;&#60; 1; // dec = 2, bit = 0010  const FLAG_C:uint = 1 &#60;&#60; 2; // dec &#8230; <a href="http://jwopitz.wordpress.com/2012/02/13/using-bitflags-and-bitwise-math/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=614&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h4>[note to self]</h4>
<p>given the following:</p>
<pre>const FLAG_A:uint = 1 &lt;&lt; 0; // dec = 1, bit = 0001
const FLAG_B:uint = 1 &lt;&lt; 1; // dec = 2, bit = 0010 
const FLAG_C:uint = 1 &lt;&lt; 2; // dec = 4, bit = 0100
const FLAG_D:uint = 1 &lt;&lt; 3; // dec = 8, bit = 1000 

var flags:uint;</pre>
<p>so if flags = 0, then we have no flags set, however if flags &gt;= 1 then we have some flags assigned.  This makes it quite easy to check by simply saying:</p>
<pre>flags = 0;
trace( Boolean( flags )); // false

flags = FLAG_A | FLAG_C; //dec = 5, bit = 0101
trace( Boolean( flags )); // true</pre>
<h1>adding flags w/ bitwise OR</h1>
<p>let&#8217;s do some adding of some values to our flags:</p>
<pre>flags = 0;
flags = FLAG_A | FLAG_C | FLAG_D; //dec = 13, bit = 1101</pre>
<p>this basically says in decimal type notation:</p>
<pre>flags = FLAG_A + FLAG_C + FLAG_D;</pre>
<p>And indeed you could use regular decimal operators and come to the same value, but where decimal operations fail is in being able to continually assign a flag of the same value multiple times as in this case:</p>
<pre>//initialize the flags
var bitflag:uint = FLAG_A | FLAG_C | FLAG_D; //dec = 13, bit = 1101
var decflag:uint =  FLAG_A + FLAG_C + FLAG_D; //dec = 13, bit = 1101</pre>
<p>Let&#8217;s assume that logic elsewhere isn&#8217;t aware of the initial value and decides to add an additional flag, in this case, one that was previously assigned.  Think of the invalidation mechanisms, setting one prop might call invalidateProps, and then subsequent props settings also calls invalidateProps&#8230; sorta analogous right?</p>
<pre>bitflag = bitflag | FLAG_A; //dec = 13, bit = 1101</pre>
<p>Note that the flag remains the same value.  This is due to the fact that the bitwise OR does not carry over like traditional addition.  In fact this could be viewed more along the lines of a logic operation for each radix.  Now let&#8217;s see if the same holds true for traditional decimal operations:</p>
<pre>decflag = decflag + FLAG_A; //dec = 14, bit = 1110</pre>
<p>Not only did the decimal operation fail us, it also set another flag for us unintentionally.  Note that 1110 is the same as:</p>
<pre>FLAG_B | FLAG_C | FLAG_D; //dec = 14, bit = 1110</pre>
<p>Ok so we&#8217;ve seen how the bitmath operations allow us to add flags without having to worry about the whole carry over issue.</p>
<p>Now let&#8217;s look at the Bitwise OR operation in more depth.  In logic, if A OR B then TRUE (forgive me, I have since forgotten the proper syntax for logic statements).  In the case of bitmath, for a given radix, if either one of them is a value of 1, then the radix for the output is 1.  The only time the radix to the output is 0 is if both values for that radix are zero.  A picture is worth a 1000 words so:</p>
<pre>       0001 - FLAG_A
  (or) 0010 - FLAG_B
------------
       0011 - flags</pre>
<p>let&#8217;s now show that adding FLAG_B again does nothing to the output:</p>
<pre>       0011 - flags
  (or) 0010 - FLAG_B
------------
       0011 - flags</pre>
<p>let&#8217;s try a more complex example:</p>
<pre>       0001 - FLAG_A
  (or) 0010 - FLAG_B
  (or) 1000 - FLAG_D
------------
       1011 - flags</pre>
<p>next up is what I&#8217;d call a HAS FLAG operation</p>
<h1>check for a flag w/ bitwise AND</h1>
<p>Bitwise OR operations are great for setting flags, but it doesn&#8217;t get you very far when you need to check your flags for a particular value.  Just like the OR operation, the AND operation is a logic operation.  If A AND B then TRUE, or in other words, for a given radix, if both values in a given radix are 1 then the output for that radix is 1, else it&#8217;s 0.  Another look at this is:</p>
<pre>       0001
 (and) 0001
------------
       0001 - both were 1 so output to 1
       0001
 (and) 0000
------------
       0000 - the logical AND statement fails, thus 0 is returned</pre>
<p>One thing to note is that the AND statement only evaluates for the 1s in the binary values (or at least how I understand it to operate).</p>
<p>So let&#8217;s apply this to our flags to see how we might be able to determine if a value is present in our flags var.  Let&#8217;s assume our flags have already been set to:</p>
<pre>flags = FLAG_A | FLAG_D; //dec = 9, bit = 1001</pre>
<p>Now we&#8217;re going to check to see if FLAG_C has been set.</p>
<pre>var hasFlagC:Boolean = FLAG_C == ( flags &amp; FLAG_C );</pre>
<p>Let&#8217;s first examine the statement in the parenthesis:</p>
<pre>flags &amp; FLAG_C;
       1001 - flags
 (and) 0100 - FLAG_C
------------
       0000 - output</pre>
<p>And then we evaluate the output against the flag we&#8217;re checking for:</p>
<pre>0000 == 0100 = FALSE
or
output != FLAG_C</pre>
<p>Ergo FLAG_C was not set.  So let&#8217;s try another test that we know should return true:</p>
<pre>flags = FLAG_A | FLAG_D; //dec = 9, bit = 1001 (from before)
var hasFlagD:Boolean = FLAG_D == ( flags &amp; FLAG_D );</pre>
<p>Evaluate the parenthesis first:</p>
<pre>flags &amp; FLAG_D;
       1001 - flags
 (and) 1000 - FLAG_D
------------
       1000 - output

output == FLAG_D</pre>
<p>Lastly there is the need to remove a flag</p>
<h1>removing a flag w/ bitwise AND plus bitwise NOT</h1>
<p>Obviously this post wouldn&#8217;t be complete without showing you how to remove a flag from a given bitflag.  This entails two types of bitwise operations.  One you are already familiar with: the bitwise AND.  The other is the bitwise NOT statement.  Like the above 2 logical operations the concept of the bitwise NOT is to return an inverse of the input:</p>
<pre>1001 - input
NOT of input
0110</pre>
<p>The common syntax is:</p>
<pre>~input</pre>
<p>So now we need to combine the AND and NOT operations to remove a flag.  Let&#8217;s dive in shall we?</p>
<pre>       0000 - flags (starting fresh)
 (and) 0001 - FLAG_A
------------
       0001 - flags
 (and) 0010 - FLAG_B
------------
       0011 - flags</pre>
<p>We&#8217;ve just added a few flags to our value.  Now let&#8217;s remove them and try to arrive at our initial state of 0.</p>
<pre>       0011 - flags
 (and) 1110 - ~FLAG_A
------------
       0010 - flags (see how the AND statement preserve FLAG_B?, now let's remove B)
 (and) 1101 - ~FLAG_B
------------
       0000 - flags (back to default state of no flags set)</pre>
<p>Now I will show you that whole process in actionscript:</p>
<pre>const FLAG_A:uint = 1 &lt;&lt; 0; // dec = 1, bit = 0001
const FLAG_B:uint = 1 &lt;&lt; 1; // dec = 2, bit = 0010 
const FLAG_C:uint = 1 &lt;&lt; 2; // dec = 4, bit = 0100
const FLAG_D:uint = 1 &lt;&lt; 3; // dec = 8, bit = 1000 

var flags:uint;
//adding A, you can also say flags |= FLAG_A; 
flags = flags | FLAG_A;

//add flag b, this time using the shorthand
flags |= FLAG_B;

//now to remove A
flags = flags &amp; ~FLAG_A;

//remove B using shorthand
flags &amp;= ~FLAG_B;

trace(flags.toString()); // 0</pre>
<h1>and the surprise is&#8230;</h1>
<p>Adobe made a nifty little utility class just for these types of operations.  Check it out:</p>
<pre>mx.utils.BitFlagUtil;</pre>
<p>It&#8217;s an excluded class so you will need to import &amp; instantiate manually, THEN code hints will appear.  Here is the documentation for it:</p>
<p><a href="http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/projects/framework/src/mx/utils/BitFlagUtil.as">link</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jwopitz.wordpress.com/614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jwopitz.wordpress.com/614/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=614&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jwopitz.wordpress.com/2012/02/13/using-bitflags-and-bitwise-math/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/290aadf0da43aaaf3cf84934c9c42bf5?s=96&#38;d=http%3A%2F%2F2.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jwopitz</media:title>
		</media:content>
	</item>
		<item>
		<title>as3 code obfuscator</title>
		<link>http://jwopitz.wordpress.com/2012/02/01/as3-code-obfuscator/</link>
		<comments>http://jwopitz.wordpress.com/2012/02/01/as3-code-obfuscator/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 18:39:46 +0000</pubDate>
		<dc:creator>jwopitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[actionScript]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[obfuscation]]></category>
		<category><![CDATA[protection]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=608</guid>
		<description><![CDATA[Wanted to share this real quick with folks. problem I have been working hard on the as3isolib.v2 trying to prep a test release.  As I haven&#8217;t decided on a licensing scheme nor do I want to freely release the source, &#8230; <a href="http://jwopitz.wordpress.com/2012/02/01/as3-code-obfuscator/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=608&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Wanted to share this real quick with folks.</p>
<h1>problem</h1>
<p>I have been working hard on the as3isolib.v2 trying to prep a test release.  As I haven&#8217;t decided on a licensing scheme nor do I want to freely release the source, I needed a way to obfuscate the source code of some of the underlying engine code.  Everything I have seen so far on the web didn&#8217;t allow for you to manipulate an individual .as file and preserve the non-private APIs.  It seems rather that most obfuscation programs target out-going SWFs from being decompiled.</p>
<h2>desired results</h2>
<ul>
<li>be able to preserve original, human-readable source file while producing an obfuscated file</li>
<li>be able to preserve the non-private variable, functions and consts</li>
<li>be able to integrate into an ANT build script</li>
</ul>
<h1>solution</h1>
<p>After doing some digging, I found this nifty little python script by Erik Johnson (<a href="http://www.applesaucejuice.net/">http://www.applesaucejuice.net/</a>) that does the first and third things I needed.  After looking at it and figuring out some real basic python, I modified the script to only obfuscate private and function-scoped members:</p>
<ul>
<li>mod&#8217;d version (<a href="http://www.pastie.org/3297122">pastebin</a>)(<a href="http://www.pastie.org/pastes/3297122/download">download</a>) - <span style="color:#ff0000;"><em>you may encounter some indentation errors when running the script as I do not have a dedicated python IDE</em></span></li>
<li>original version (<a href="https://github.com/shapedbyregret/actionscript-3-obfuscator">github</a>)</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jwopitz.wordpress.com/608/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jwopitz.wordpress.com/608/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=608&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jwopitz.wordpress.com/2012/02/01/as3-code-obfuscator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/290aadf0da43aaaf3cf84934c9c42bf5?s=96&#38;d=http%3A%2F%2F2.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jwopitz</media:title>
		</media:content>
	</item>
		<item>
		<title>Monthly Expenses Template via Google Spreadsheets</title>
		<link>http://jwopitz.wordpress.com/2012/01/13/monthly-expenses-template-via-google-spreadsheets/</link>
		<comments>http://jwopitz.wordpress.com/2012/01/13/monthly-expenses-template-via-google-spreadsheets/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 23:21:25 +0000</pubDate>
		<dc:creator>jwopitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=606</guid>
		<description><![CDATA[I&#8217;ve been keeping track of all my monthly expenses in order to reign in my spending.  I absolutely LOVE google docs&#8217; spreadsheets.  Here is the template I am using if you&#8217;d like to use it.  Please feel free to add &#8230; <a href="http://jwopitz.wordpress.com/2012/01/13/monthly-expenses-template-via-google-spreadsheets/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=606&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been keeping track of all my monthly expenses in order to reign in my spending.  I absolutely LOVE google docs&#8217; spreadsheets.  Here is the template I am using if you&#8217;d like to use it.  Please feel free to add questions, suggestions &amp; comments</p>
<p><a href="https://docs.google.com/spreadsheet/ccc?key=0As9k6GLAYjwpdDNGMFZFanRweXFlRV9mUGlPeVBNSVE">https://docs.google.com/spreadsheet/ccc?key=0As9k6GLAYjwpdDNGMFZFanRweXFlRV9mUGlPeVBNSVE</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jwopitz.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jwopitz.wordpress.com/606/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=606&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jwopitz.wordpress.com/2012/01/13/monthly-expenses-template-via-google-spreadsheets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/290aadf0da43aaaf3cf84934c9c42bf5?s=96&#38;d=http%3A%2F%2F2.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jwopitz</media:title>
		</media:content>
	</item>
		<item>
		<title>Propagating Changes from Spark&#8217;s Skinnable Component to Skin</title>
		<link>http://jwopitz.wordpress.com/2011/12/14/propagating-changes-from-sparks-skinnable-component-to-skin/</link>
		<comments>http://jwopitz.wordpress.com/2011/12/14/propagating-changes-from-sparks-skinnable-component-to-skin/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 19:16:19 +0000</pubDate>
		<dc:creator>jwopitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=591</guid>
		<description><![CDATA[preface I will not be discussing the pros/cons of a Spark skin containing &#8220;awareness&#8221; of its host component&#8217;s properties.  That falls into a more in-depth &#8220;best practices&#8221; discussion to be discussed at a later time. [note to self] One way &#8230; <a href="http://jwopitz.wordpress.com/2011/12/14/propagating-changes-from-sparks-skinnable-component-to-skin/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=591&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3>preface</h3>
<p>I will not be discussing the pros/cons of a Spark skin containing &#8220;awareness&#8221; of its host component&#8217;s properties.  That falls into a more in-depth &#8220;best practices&#8221; discussion to be discussed at a later time.</p>
<h1>[note to self]</h1>
<p>One way to propagate changes from the SkinnableComponent to the Skin and still leverage the Flex framework&#8217;s invalidation mechanisms is to simply update your property and then call invalidateDisplayList.  Override your updateDisplayList call in the Skin and fetch the needed values.  For this example the particular skin I was creating needed to create a mask whose width was based on a particular value.  Seeing as this logic was particular to the skin, I decided to move the logic into the skin rather than the component itself.</p>
<h3>hostComponent code</h3>
<pre>public function set volume(value:Number):void
{
	if (value != _volume)
	{
		_volume = value;
		_volValue = _volume &lt; 0 ? 0 : _volume &gt; 1 ? 1 : _volume; //limit betw 0 &amp; 1

		bVolumeChanged = true;

		invalidateProperties();

                <span style="color:#ff0000;">if (skin)
                {
                            skin.<strong>invalidateProperties</strong>();
                            skin.<strong>invalidateDisplayList</strong>();
                }</span>
	}
}</pre>
<h2></h2>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jwopitz.wordpress.com/591/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jwopitz.wordpress.com/591/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=591&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jwopitz.wordpress.com/2011/12/14/propagating-changes-from-sparks-skinnable-component-to-skin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/290aadf0da43aaaf3cf84934c9c42bf5?s=96&#38;d=http%3A%2F%2F2.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jwopitz</media:title>
		</media:content>
	</item>
		<item>
		<title>variable instantiation via anonymous functions</title>
		<link>http://jwopitz.wordpress.com/2011/12/08/variable-instantiation-via-anonymous-functions/</link>
		<comments>http://jwopitz.wordpress.com/2011/12/08/variable-instantiation-via-anonymous-functions/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 16:30:50 +0000</pubDate>
		<dc:creator>jwopitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=580</guid>
		<description><![CDATA[[Note to Self] rather than: var foo:Object = function ():Object {    var o:Object = {};    o.id = "foo";    o.data = Math.random();    return o; }; //will fail with a CTE cannot coerce function to object you need &#8230; <a href="http://jwopitz.wordpress.com/2011/12/08/variable-instantiation-via-anonymous-functions/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=580&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>[Note to Self]</p>
<p>rather than:</p>
<pre>var foo:Object = function ():Object
{
   var o:Object = {};
   o.id = "foo";
   o.data = Math.random();

   return o;
}; <span style="color:#3366ff;">//will fail with a CTE cannot coerce function to object</span></pre>
<p>you need only add this:</p>
<pre><span style="color:#808080;">var foo:Object = function ():Object { .... }</span><span style="color:#ff0000;"><strong>()</strong></span><span style="color:#808080;">;</span> <span style="color:#3366ff;">//will succeed <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></pre>
<p>What&#8217;s going on here? Well the first will fail giving you a CTE (compile-time error) stating that you are implicitly coercing a function to an object.  And that&#8217;s true, you have in no way actually called the anonymous function in the first example.  Rather you have DECLARED it.</p>
<p>The second bit of code is still declaring/defining the function however you are immediately calling said function afterward.</p>
<p>Not necessarily a best practice but a good trick to add to your bag o&#8217; tricks.  Thanks to Nicola Bortignon (<a href="http://www.nicolabortignon.com/">http://www.nicolabortignon.com/</a>) for showing me this.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jwopitz.wordpress.com/580/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jwopitz.wordpress.com/580/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=580&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jwopitz.wordpress.com/2011/12/08/variable-instantiation-via-anonymous-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/290aadf0da43aaaf3cf84934c9c42bf5?s=96&#38;d=http%3A%2F%2F2.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jwopitz</media:title>
		</media:content>
	</item>
		<item>
		<title>Spark Label linebreak</title>
		<link>http://jwopitz.wordpress.com/2011/11/21/spark-label-linebreak/</link>
		<comments>http://jwopitz.wordpress.com/2011/11/21/spark-label-linebreak/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 19:19:00 +0000</pubDate>
		<dc:creator>jwopitz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jwopitz.wordpress.com/?p=576</guid>
		<description><![CDATA[[Note to Self] You can&#8217;t simply set the text of an MXML declared Spark Label like below and expect linebreak or carriage returns to work: &#60;s:Label text="this is where I desire my line break to be\nnow the second line begins....." &#8230; <a href="http://jwopitz.wordpress.com/2011/11/21/spark-label-linebreak/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=576&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>[Note to Self]</p>
<p>You can&#8217;t simply set the text of an MXML declared Spark Label like below and expect linebreak or carriage returns to work:</p>
<pre>&lt;s:Label text="this is where I desire my line break to be\nnow the second line begins....." 
         maxDisplayedLine="2"/&gt;</pre>
<p>You now have to explicitly wrap the linebreak or carriage return in binding brackets and single quotes like so:</p>
<pre>&lt;s:Label text="this is where I desire my line break to be{'\n'}now the second line begins....." 
         maxDisplayedLine="2" 
         lineBreak="explicit"/&gt;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jwopitz.wordpress.com/576/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jwopitz.wordpress.com/576/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jwopitz.wordpress.com&#038;blog=506032&#038;post=576&#038;subd=jwopitz&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jwopitz.wordpress.com/2011/11/21/spark-label-linebreak/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/290aadf0da43aaaf3cf84934c9c42bf5?s=96&#38;d=http%3A%2F%2F2.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">jwopitz</media:title>
		</media:content>
	</item>
	</channel>
</rss>
