<?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>Ghostmonk Journal &#187; Object Oriented Design</title>
	<atom:link href="http://journal.ghostmonk.com/category/object_oriented_design/feed/" rel="self" type="application/rss+xml" />
	<link>http://journal.ghostmonk.com</link>
	<description>Pontificate, Obfuscate, Simplify and Reveal</description>
	<lastBuildDate>Mon, 18 Jan 2010 02:15:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Particle Play With Perlin Noise</title>
		<link>http://journal.ghostmonk.com/design/perlin_noise_particles/</link>
		<comments>http://journal.ghostmonk.com/design/perlin_noise_particles/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 00:00:36 +0000</pubDate>
		<dc:creator>ghostmonk</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Interactive]]></category>
		<category><![CDATA[Object Oriented Design]]></category>
		<category><![CDATA[experiment]]></category>

		<guid isPermaLink="false">http://journal.ghostmonk.com/?p=202</guid>
		<description><![CDATA[Particle system controlled with perlin data. A control panel allows access to a number of input variables to control the perlin data and particle output.]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
swfobject.embedSWF("/wp-content/themes/default/flash/PerlinNoisePlay.swf", "perlinParticles", "470", "470", "9.0.0", "", {}, { bgcolor:"#000000" });
// --></script></p>
<div id="perlinParticles">
<p>You need Flash 9 to see this awesome Perlin noise particle system!</p></div>
<p>This is an early iteration of the system but I think it&#8217;s at a good point to publish. I just saw Mario Klingerman present at the FITC, and now I have a ton of new ideas to continue exploring and experimenting. If only I had some more free time.</p>
<p>Eventually I plan to release the code, but not until I&#8217;ve explored the possibility a little further.</p>
]]></content:encoded>
			<wfw:commentRss>http://journal.ghostmonk.com/design/perlin_noise_particles/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Internal Build Error: Flash -&gt; SWC + Flex = BitmapData Insanity</title>
		<link>http://journal.ghostmonk.com/actionscript3/internal-build-error-flash-swc-flex-bitmapdata-insanity/</link>
		<comments>http://journal.ghostmonk.com/actionscript3/internal-build-error-flash-swc-flex-bitmapdata-insanity/#comments</comments>
		<pubDate>Sat, 16 Feb 2008 15:12:57 +0000</pubDate>
		<dc:creator>ghostmonk</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[Object Oriented Design]]></category>

		<guid isPermaLink="false">http://journal.ghostmonk.com/?p=55</guid>
		<description><![CDATA[I thought I would present a problem I seem to be having consistently in Flex builder, and see if anyone is searching for like issues. For some reason, Flex Builder is not handling Bitmap Data with any sort of consistency when it is included as a class in a SWC exported from Flash. In my [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I would present a problem I seem to be having consistently in Flex builder, and see if anyone is searching for like issues.</p>
<p>For some reason, Flex Builder is not handling Bitmap Data with any sort of consistency when it is included as a class in a SWC exported from Flash. In my opinion, using SWCs to import visual content from the Flash IDE, is for the most part a fluid and excellent work flow. However, every once in a while, in seemingly inexplicable fashion, I get internal build errors.</p>
<p><span id="more-55"></span>The insanity of this is that I can&#8217;t find a pattern. It happens mainly on library objects exported as BitmapData, but not consistently. In one project for instance, I received an internal build error, and was able to whittle the problem down to one tiny BitmapData culprit in a library of about 40 like classes.</p>
<p>By eliminating the offending class, my Flex ActionScript Project compiles&#8230;. if I don&#8217;t, Flex blows up and I get an &#8220;internal build error.&#8221; There are annoying workarounds, like embedding the Bitmap into the ActionScript Class, but this ruins the fluidity of a work-flow between Flash and Flex.</p>
<p>Anyway, the whole thing throws a monkey wrench into the system, and is overwhelmingly irritating. I wish I could post a solution, but I haven&#8217;t been able to nail down the real problem. Also, there seems to be next to nothing concerning this problem on the web.</p>
<p>A colleague mentioned that it might have something to do with the sensitivity of the Eclipse Framework, but god only knows at this point. So, there you have it. I may be the only one wrestling with this issue, and I may never receive a comment on this post, but hopefully someone out there knows what I&#8217;m talking about and can share in my pain.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>This is a simplified version of including a SWC file in a flex project&#8230; you can read the complete document at <a href="http://livedocs.adobe.com/labs/flex3/html/help.html?content=projects_7.html">Adobe&#8217;s LiveDocs</a></p>
<p><strong>Add an SWC file to the library path</strong></p>
<ol>
<li>With a project selected in the Flex Navigator view, select Project &gt; Properties &gt; Flex Build Path.</li>
<li>Click on the Library tab.</li>
<li>Select the <dfn class="term">Add SWC option</dfn></li>
<li>Enter or browse to and select the location of the SWC file, project, or folder. Click OK.The SWC file, library project, or folder is added to the library path.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://journal.ghostmonk.com/actionscript3/internal-build-error-flash-swc-flex-bitmapdata-insanity/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Globally set your tweens man!</title>
		<link>http://journal.ghostmonk.com/actionscript3/globally-set-your-tweens-man/</link>
		<comments>http://journal.ghostmonk.com/actionscript3/globally-set-your-tweens-man/#comments</comments>
		<pubDate>Fri, 23 Nov 2007 17:26:27 +0000</pubDate>
		<dc:creator>ghostmonk</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Object Oriented Design]]></category>

		<guid isPermaLink="false">http://journal.ghostmonk.com/?p=49</guid>
		<description><![CDATA[Lately I&#8217;ve been using the Tween class included in the flash ActionScript 3.0 for Flash CS3 library, and I noticed some peculiar behavior with respect to the motion of the Tweens. Often, especially when the program was undergoing points of extreme activity, my tweens would not complete their motions. It was perplexing, and my first [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://journal.ghostmonk.com/?page_id=52" title="Vicious Gnawing Worms"><img src="http://journal.ghostmonk.com/wp-content/uploads/2007/11/viciousworms_thumb.jpg" alt="Vicious Worms" border="0" /></a></p>
<p>Lately I&#8217;ve been using the Tween class included in the flash ActionScript 3.0 for Flash CS3 library, and I noticed some peculiar behavior with respect to the motion of the Tweens. Often, especially when the program was undergoing points of extreme activity, my tweens would not complete their motions. It was perplexing, and my first attempt to fix the bug was to simply to listen for the tween to stop</p>
<pre>(tween.addListener(TweenEvent.MOTION_FINISH,
                   fixPosition)</pre>
<p>, and then to force the asset to its intended end point. This worked on a simple application: <a href="http://selectedwork.ghostmonk.com">Selected Works Site</a>, but it completely failed when I tried it on one with heavy processor activity.</p>
<p>So, after trawling the internet in search of others experiencing the same problem, I believe I found the solution in the comments at a blog called <a href="http://alvinzhang.info/?p=4">Everything Cool</a>. (I aslo found they talked about it on the live docs). Here I&#8217;ll explain what the problem is, how to solve it, and at the same time show you how to use the fl.transitions.Tween class in Flash CS3.</p>
<p><span id="more-49"></span>A quick tutorial on the Tween Class.<br />
First a few points.</p>
<ol>
<li>You always need to import the tween class when using tweens, even when coding on the timeline of an fla</li>
<li>Tweens can be used on almost any kind of object, unlike the transition manager which forces your target to be a MovieClip</li>
<li>The Flex framework has its own class of Tweens that work differently than the ones I&#8217;m describing here. You will need to search the web to figure out how to use these.</li>
</ol>
<p>Ok, so I&#8217;m providing generalized code. The first 2 lines are the import statements, the 3rd is the variable declaration, and the remaining lines will be the actual tween itself, inside of a function that you can call anywhere. A tween automatically starts when it is called.</p>
<pre>
import fl.transitions.Tween;
import fl.transitions.easing.*;

var simpleMovement:Tween

private function startTween(e:MouseEvent):void{
   simpleMovement = new Tween(targetObject, "y",
 		      Strong.easeOut,
 		      targetObject.y,
 		      destinationValue,
 		      1, true);
}</pre>
<p>You will see that the tween called &#8220;simpleMovement&#8221; takes 7 arguments. They are as follows (in order):</p>
<ol>
<li>Object to be tweened</li>
<li>Value to be tweened. (Can be pretty much anything you desire&#8230; even filter values and sound volume)</li>
<li>Easing method(you must import the easing class as supplied)</li>
<li>Start value (supplied in this example as wherever the target object is currently located)</li>
<li>End Value</li>
<li>Length of tween in seconds. (a highly precise number&#8230; can use 0.3482)</li>
<li>Use seconds&#8230; either true or false.</li>
</ol>
<p>Now the problem I was having had to do with the scope of declaring my Tween object. Out of simple cohesion, or laziness I often put my tween declarations and the instantiations in the same function.</p>
<pre>private function startTween(e:MouseEvent):void{
   var simpleMovement:Tween = new Tween(
                      targetObject, "y",
 		      Strong.easeOut,
 		      targetObject.y,
 		      destinationValue,
 		      1, true);
}</pre>
<p>Well therein was my problem. In ActionScript 3.0, the garbage collector runs whenever there is a high number of discarded objects in the cue. (The garbage collector deletes objects with no reference) Because my tween was declared locally, and thus a weak reference, if the application went through an episode of high activity, it was highly likely that it would be discarded by the garbage collector before it could complete.</p>
<p>So eureka man, all I had to do was declare my Tween globally, and thus ensure the garbage collector wouldn&#8217;t mark it for deletion.</p>
]]></content:encoded>
			<wfw:commentRss>http://journal.ghostmonk.com/actionscript3/globally-set-your-tweens-man/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Accessors and Mutators</title>
		<link>http://journal.ghostmonk.com/actionscript3/accessors-and-mutators/</link>
		<comments>http://journal.ghostmonk.com/actionscript3/accessors-and-mutators/#comments</comments>
		<pubDate>Sat, 25 Aug 2007 18:39:52 +0000</pubDate>
		<dc:creator>ghostmonk</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Object Oriented Design]]></category>

		<guid isPermaLink="false">http://journal.ghostmonk.com/?p=25</guid>
		<description><![CDATA[**Warning: The following post is about Object Oriented Design, and may be VERY annoying for those who don&#8217;t spend a STUPID amount of time in front of the computer reading the driest material ever known to mankind. ** For those into OOD/OOP, please read on&#8230; This is my attempt to make lucid some very spiraling [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://journal.ghostmonk.com/?page_id=31" title="mutator thumb"><img src="http://journal.ghostmonk.com/wp-content/uploads/2007/08/thumb.jpg" alt="mutator thumb" align="left" hspace="10" vspace="10" /></a><em>**Warning: The following post is about Object Oriented Design, and may be VERY annoying for those who don&#8217;t spend a STUPID amount of time in front of the computer reading the driest material ever known to mankind.  **</em></p>
<p>For those into OOD/OOP,  please read on&#8230; This is my attempt to make lucid some very spiraling concepts. I&#8217;m no expert, I&#8217;m a budding programmer, so as such I may be able to present these ideas with a new perception. At any rate&#8230; getting them down on paper solidifies the methods in my mind. That&#8217;s why I&#8217;m sparse on code, and big on concept. So if I get anything wrong, feel free to send evocative comments, I love the sweet vigor of a verbal joust.</p>
<p>Note: All OOD jargon has been <em>italicized and colored</em> for no good reason at all.</p>
<p><span id="more-25"></span></p>
<p><strong>Summary</strong></p>
<p><em>Getter</em> and <em>setter methods</em> in ActionScript3 differ from regular methods, and resemble <em>characteristics</em> of <em>objects</em>. They do not use regular <em>call statement</em> form, but use <em>dot notation</em> (as a <em>variable</em> would). To use them, you simply call an <em>instantiated object</em> through its <em>variable name</em> and append the <em>getter or setter method</em> minus the <em>function call operator</em>.  It&#8217;s a prety nice and succinct way to modify states of an object.</p>
<p><strong>Defining The Class </strong></p>
<p>Let&#8217;s assume we have a <em>class</em> called <em>&#8220;humanEntity()&#8221;</em>, and in this <em>class</em> we declare a <em>private instance variable</em> called <em>&#8220;lbs&#8221;</em> describing its size. Through the <em>constructor method</em>, we pass a <em>parameter</em> called <em>&#8220;mass&#8221;</em> without an <em>initializer</em> so it is required in the <em>instantiation</em> of the object. In the <em>constructor</em> we assign the value of <em>&#8220;mass&#8221;</em> to the class&#8217;s <em>instance variable &#8220;lbs&#8221;</em> with an <em>assignment operator.</em></p>
<p>Great, now all is set to define our <em>getter </em>and <em>setter </em>methods. (These are also loosely known as <em>mutators, accessors, modifiers and retrievers</em>&#8230;. what a roguish set of descriptors). Good getters and setters have identical method names and are defined not as actions (as a normal method might be) but as <em>characteristics</em>. So instead of using <em>&#8220;changeWeight&#8221;</em> or <em>&#8220;returnWeight&#8221;</em> we would use one variable called <em>&#8220;weight&#8221;</em>. Through these methods, we can change and return the <em>private variable &#8220;lbs&#8221;</em> to a main program that uses the <em>&#8220;humanEntity()&#8221; object</em>. By definition, a getter method explicitly returns a value&#8230; in this case <em>&#8220;lbs&#8221;</em>, and a setter method alters that value. Setters automatically return values, but it is illegal to use a <em>return statement </em>in a setter method.</p>
<p>They are defined like this.</p>
<pre>function get weight():Number{
return lbs;
}</pre>
<pre>function set weight(newLbs:Number):void{
lbs = newLbs;
}</pre>
<p>Note that the method name is exactly the same in both. It is the <em>keywords &#8220;get&#8221; and &#8220;set&#8221;</em> that differentiate them.</p>
<p><strong>Recap</strong></p>
<p>So to recap, we have a class named <em>&#8220;humanEntity()&#8221;</em> with a <em>private instance variable</em> named <em>&#8220;lbs&#8221;.  &#8220;lbs&#8221;</em> is assigned through the <em>constructor method</em> with a <em>required parameter </em>called <em>&#8220;mass&#8221;</em>. There is one <em>getter method</em> and one <em>setter method</em>, both named <em>&#8220;weight&#8221;</em>.</p>
<p><em>Just as an aside, you might want to create another method in this class that would set sensible default values to &#8220;mass&#8221; if someone tried to pass a value  into the object that was too high or low.  You would use a conditional statement of some sort. (I guess that&#8217;s for another discussion).</em></p>
<p><strong>Instantiating the Object</strong></p>
<p>Alright, so now we are using the <em>&#8220;humanEntity()&#8221; class</em> in our application, and we will assign the object to a variable called <em>&#8220;conradVonDuchance&#8221;</em>. Based on everything I have written thus far, it is <em>instantiated</em> into our main class (or whatever class) thusly.</p>
<pre>private var conradVonDuchance:humanEntity
= new humanEntity(200);</pre>
<p><strong>The Crux </strong></p>
<p>Sweet, now for the crux of this entire article.</p>
<p>What makes getter and setter methods so cool, is that you can now both reset and return <em>&#8220;lbs&#8221;</em> (the private variable) by using the method <em>&#8220;weight&#8221;</em>.</p>
<p><strong>Here are two Examples:<br />
</strong>Setting a dynamic style variable to the <em>&#8220;weight&#8221;</em> getter of our object:</p>
<pre>var conradSize:Number = conradVonDuchance.weight;
return conradSize;</pre>
<p>To reset <em>&#8220;weight&#8221;</em>:</p>
<pre>conradVonDuchance.weight = 220;</pre>
<p><strong>Why this is good</strong></p>
<p>At first glance this might seem like a ton of work to accomplish, but I feel it vastly improves your class&#8217;s <em>API</em>.</p>
<p>The idea of setting and returning a characteristic of an object should be as intuitive as possible, and having to call two different methods with different names and  <em>function call operators</em>, to accomplish this is a little cumbersome and ugly. Using the methods <em>&#8220;getWeight()&#8221;</em> and <em>&#8220;setWeight()&#8221;</em>, do makes sense but do not feel streamlined and sexy.</p>
<p>And after all&#8230; isn&#8217;t that what programming is all about&#8230; making the most streamlined sexy block of code possible so you can appeal to the opposite (or same) sex.</p>
]]></content:encoded>
			<wfw:commentRss>http://journal.ghostmonk.com/actionscript3/accessors-and-mutators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
