<?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>ActionScript 3.0 Design Patterns &#187; ActionScript</title>
	<atom:link href="http://www.as3dp.com/category/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.as3dp.com</link>
	<description>OOP Techniques for Flash and Flex Developers</description>
	<lastBuildDate>Sun, 29 Jan 2012 17:00:46 +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>ActionScript 3.0 GestureEvent: Working with Gestures on Mobile</title>
		<link>http://www.as3dp.com/2012/01/actionscript-3-0-gestureevent-working-with-gestures-on-mobile/</link>
		<comments>http://www.as3dp.com/2012/01/actionscript-3-0-gestureevent-working-with-gestures-on-mobile/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 17:00:46 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=6415</guid>
		<description><![CDATA[Using Gestures When working with high level and complex structures like Design Patterns, the focus is squarely on the relationship between objects—classes, inheritance, composition, implementation, interfaces and related concepts and structures. The &#8220;details&#8221; are the details of these various relationships and how they work in concert. Using Algorithm 1 or Algorithm 2 is only pertinent [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.as3dp.com/wp-content/uploads/2012/01/billz.png"><img src="http://www.as3dp.com/wp-content/uploads/2012/01/billz.png" alt="Developing Gesture Apps Requires Actions with No Equivalent in MouseEvents" title="billz" width="250" height="188" class="alignleft size-full wp-image-6445" /></a><strong>Using Gestures</strong></p>
<p>When working with high level and complex structures like <strong>Design Patterns</strong>, the focus is squarely on the relationship between objects—classes, inheritance, composition, implementation, interfaces and related concepts and structures. The &#8220;details&#8221; are the details of these various relationships and how they work in concert. Using <strong>Algorithm 1</strong> or <strong>Algorithm 2</strong> is only pertinent insofar as it relates to a method or property that needs to be loosely bound to some other object. If you start thinking about algorithm details as a primary concern and fretting over internals, you can easily lose sight of the larger structures that are under development and never really understand <strong>Design Patterns</strong>.</p>
<p><strong>Seismic Shift</strong></p>
<p>Every now and again we encounter a <em>seismic shift</em> in the way things are done, and you have to make adjustments.(Some of you may remember the <strong>Commodore 64</strong> that went the way of the Dodo Bird. At one time it was the most popular personal computer on earth, but if you insisted on sticking with it, you probably don&#8217;t have any clients for your services.) In my own case, shift to mobile devices forced me to spend some quality time with the event processes in ActionScript 3.0. Going to the base, I reviewed how the Display List is handled in Flash and by AS3. Then I went to look at the AS3 Event Flow and among the several articles I read, one of the best is <a href="http://www.actionscript.org/resources/articles/860/1/Understanding-the-AS3-Event-Flow/Page1.html">Jody Hall&#8217;s</a>. Adobe has several good ones as well, and I&#8217;m sure many more are available that some of you may want to share.</p>
<p><strong>On to Gestures</strong></p>
<p>I wrote some gesture events and handlers. The results were unsatisfactory. It wasn&#8217;t that they didn&#8217;t work, but after one would work, another would not. Very baffling and frustrating. My goal was to create a &#8216;workbench&#8217; where I could try all kinds of gesture events, but I had very poor luck with just about everything at some point. So I backed away and tried an application with only two gestures; neither available with MouseEvent. One was <strong>Rotate</strong> and the other <strong>Zoom</strong>. Christian Cantrell has a <a href="http://www.adobe.com/devnet/flash/articles/multitouch_gestures.html">good article</a> on using gestures, and in addition to getting some good information on using gesture events, I also got a nice little piece on using gestures with bitmaps. (I had been having a devil of a time with Sprite objects in the Library with gestures.) Click the download button below to get the source code and FLA files for Flash Pro 5.5, 5 and 4 along with the image files and ActionScript 3.0 code:</p>
<p><a href="http://www.sandlight.com/DesignPatterns/PicFlip.zip"><img src="http://www.as3dp.com/wp-content/uploads/2012/01/download.png" alt="download this sucker" title="download" width="136" height="48" class="alignnone size-full wp-image-6426" /></a></p>
<p>In my last post, I was convinced that <strong>TOUCH_TAP</strong> from <strong>TouchEvent</strong> works better than <strong>CLICK</strong> from <strong>MouseEvent</strong> with a mobile device. That conclusion was not based on the inner-workings of events and event handling, but rather from testing the different event handlers using my iOS device, a 4S iPhone. In the Adobe documentation, they point out that it <em>might be better</em> to use a <strong>MouseEvent</strong> rather than a <strong>TouchEvent</strong> or <strong>GestureEvent</strong>. It depends on the app, device and device OS. That pretty much makes it an empirical question.</p>
<p>In this application, there was no choice to use <strong>MouseEvent</strong> because it does not contain the required finger-flipping gestures I can make on my iPhone—<strong>GESTURE_ZOOM</strong> and <strong>GESTURE_ROTATE</strong>. Likewise, <strong>TouchEvent</strong> did not have the kinds of gestures; so I had to use <strong>TransformGestureEvent</strong>. The following code shows how it is employed in a simple picture flipping/zooming app:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6415code3'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p64153"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre></td><td class="code" id="p6415code3"><pre class="actionscript" style="font-family:monospace;">package 
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Bitmap</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">TransformGestureEvent</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">ui</span>.<span style="color: #006600;">Multitouch</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">ui</span>.<span style="color: #006600;">MultitouchInputMode</span>;
&nbsp;
	<span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">width</span>=<span style="color: #cc66cc;">640</span>, <span style="color: #0066CC;">height</span>=<span style="color: #cc66cc;">960</span>, frameRate=<span style="color: #cc66cc;">24</span>, <span style="color: #0066CC;">backgroundColor</span>=0xcc0000<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PicFlip <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source = <span style="color: #ff0000;">&quot;vanBillz.png&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> BillzImage:<span style="color: #000000; font-weight: bold;">Class</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> billzBitmap:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> BillzImage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> carrier:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> PicFlip<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			carrier.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">320</span>, carrier.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">550</span>;
			carrier.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>billzBitmap<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			billzBitmap.<span style="color: #006600;">x</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">320</span> - <span style="color: #66cc66;">&#40;</span>billzBitmap.<span style="color: #006600;">bitmapData</span>.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> -<span style="color: #cc66cc;">1</span>;
			billzBitmap.<span style="color: #006600;">y</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">480</span> - <span style="color: #66cc66;">&#40;</span>billzBitmap.<span style="color: #006600;">bitmapData</span>.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span>-<span style="color: #cc66cc;">1</span>;
&nbsp;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>carrier<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			Multitouch.<span style="color: #006600;">inputMode</span> = MultitouchInputMode.<span style="color: #006600;">GESTURE</span>;
			carrier.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TransformGestureEvent.<span style="color: #006600;">GESTURE_ZOOM</span>, doZoom<span style="color: #66cc66;">&#41;</span>;
			carrier.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TransformGestureEvent.<span style="color: #006600;">GESTURE_ROTATE</span>, doRotate<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> final <span style="color: #000000; font-weight: bold;">function</span> doZoom<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:TransformGestureEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			carrier = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span> as Sprite;
			carrier.<span style="color: #006600;">scaleX</span> <span style="color: #66cc66;">*</span>=  <span style="color: #0066CC;">e</span>.<span style="color: #006600;">scaleX</span>;
			carrier.<span style="color: #006600;">scaleY</span> <span style="color: #66cc66;">*</span>=  <span style="color: #0066CC;">e</span>.<span style="color: #006600;">scaleY</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> final <span style="color: #000000; font-weight: bold;">function</span> doRotate<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:TransformGestureEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			carrier = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span> as Sprite;
			carrier.<span style="color: #006600;">rotation</span> +=  <span style="color: #0066CC;">e</span>.<span style="color: #006600;">rotation</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>I tested it on an iPhone, but there&#8217;s no reason it won&#8217;t work perfectly well on an Android or some other mobile device. Further, I found it to be very responsive. The zooming seemed to work quite well with bitmapped graphics, and so I assumed that it would work just as well, if not better with a vector object in the Library. So I put together a little test symbol using the drawing tools in Flash and stored it as  Sprite class in the Library. (By the way, in case you were not aware, to make a Sprite class in the Library, when you create a New Symbol, just classify it as a MovieClip and in the Base Class window change the type from <strong>flash.display.MovieClip</strong> -> <strong>flash.display.Sprite</strong>. The Library icon turns from Blue to Green to indicate it is now a Sprite.)</p>
<p>I used the following code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6415code4'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p64154"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code" id="p6415code4"><pre class="actionscript" style="font-family:monospace;">package 
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">TransformGestureEvent</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">ui</span>.<span style="color: #006600;">Multitouch</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">ui</span>.<span style="color: #006600;">MultitouchInputMode</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PicFlipLib <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> carrier:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> billzVector:Sprite=<span style="color: #000000; font-weight: bold;">new</span> BillzVector<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> PicFlipLib<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			carrier.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">220</span>, carrier.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">350</span>;
			carrier.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>billzVector<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>carrier<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			Multitouch.<span style="color: #006600;">inputMode</span> = MultitouchInputMode.<span style="color: #006600;">GESTURE</span>;
			carrier.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TransformGestureEvent.<span style="color: #006600;">GESTURE_ZOOM</span>, doZoom<span style="color: #66cc66;">&#41;</span>;
			carrier.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TransformGestureEvent.<span style="color: #006600;">GESTURE_ROTATE</span>, doRotate<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> final <span style="color: #000000; font-weight: bold;">function</span> doZoom<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:TransformGestureEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			carrier = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span> as Sprite;
			carrier.<span style="color: #006600;">scaleX</span> <span style="color: #66cc66;">*</span>=  <span style="color: #0066CC;">e</span>.<span style="color: #006600;">scaleX</span>;
			carrier.<span style="color: #006600;">scaleY</span> <span style="color: #66cc66;">*</span>=  <span style="color: #0066CC;">e</span>.<span style="color: #006600;">scaleY</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> final <span style="color: #000000; font-weight: bold;">function</span> doRotate<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:TransformGestureEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			carrier = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span> as Sprite;
			carrier.<span style="color: #006600;">rotation</span> +=  <span style="color: #0066CC;">e</span>.<span style="color: #006600;">rotation</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>One of the features that seemed to make a difference was that instead of having the event listener connected directly to the Library Sprite (<strong>BillzVector</strong>), I used an object container Sprite, <strong>carrier</strong>. Figure 1 shows the zoom and rotation on an iPhone 4S. This was used with both the bitmap and the vector Sprite objects, and they both worked quite well.<br />
<div id="attachment_6460" class="wp-caption alignnone" style="width: 510px"><a href="http://www.as3dp.com/wp-content/uploads/2012/01/rotateZoom.png"><img src="http://www.as3dp.com/wp-content/uploads/2012/01/rotateZoom.png" alt="rotate" title="rotateZoom" width="500" height="372" class="size-full wp-image-6460" /></a><p class="wp-caption-text">Figure 1: Both rotation and zoom worked fined with the vector-based Sprite</p></div></p>
<p><strong>Back to Design Patterns</strong></p>
<p>I was going to post my final matrix motion solution, but I got jammed up with event handling. Next time, I should be able to post the next stage in my Samurai game. It uses a State design pattern to move through nine cells in a 3 X 3 matrix. Everything was working well except that my event handlers were not as crisp as I wanted. I&#8217;ll have a chance to see now whether the time-out with AS3 event handlers was enough. The Design Pattern does its job; I just was not getting the event handlers to do theirs. In the next post you&#8217;ll be able to see whether they are all working well together in a mobile environment.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2012%2F01%2Factionscript-3-0-gestureevent-working-with-gestures-on-mobile%2F&amp;title=ActionScript%203.0%20GestureEvent%3A%20Working%20with%20Gestures%20on%20Mobile" id="wpa2a_2"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2012/01/actionscript-3-0-gestureevent-working-with-gestures-on-mobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript Design Patterns Transcend Changes at Adobe</title>
		<link>http://www.as3dp.com/2011/11/actionscript-design-patterns-transcend-changes-at-adobe/</link>
		<comments>http://www.as3dp.com/2011/11/actionscript-design-patterns-transcend-changes-at-adobe/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 20:15:05 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=6299</guid>
		<description><![CDATA[A lot of you may have heard the announcement from Adobe about dropping support for mobile browsers. It&#8217;s been a year and a half since we posted the article about the spat between Adobe and Apple, and now again, an announcement from Adobe has shaken things up. According to The Economist (Oct 8-14, 2011), in [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_6301" class="wp-caption alignleft" style="width: 260px"><img src="http://www.as3dp.com/wp-content/uploads/2011/11/ShiftAdobe.png" alt="If you think everyone is heading for HTML5 now, you&#039;re nuts!" title="ShiftAdobe" width="250" height="274" class="size-full wp-image-6301" /><p class="wp-caption-text">If you think everyone is heading for HTML5 now, you're nuts!</p></div>A lot of you may have heard the <a href="http://blogs.adobe.com/conversations/2011/11/flash-focus.html">announcement from Adobe</a> about dropping support for mobile browsers. It&#8217;s been a year and a half since we posted the article about the <a href="http://www.as3dp.com/2010/04/29/actionscript-3-0-developers-caught-in-the-middle/">spat between Adobe and Apple</a>, and now again, an announcement from Adobe has shaken things up.</p>
<p>According to <em>The Economist</em> (Oct 8-14, 2011), in 1993 there were 100 million PCs. By 2008, PCs had topped 1 billion. Many of us tapped into that market one way or another, and some of us came out well rewarded—Adobe certainly did. By 2020 (barely 8 years from now), they expect 10 billion mobile connected devices. In looking at the number consider this: The current #1 Free App on iOS devices is called &#8216;Hair Plucker&#8217; and who knows how many people bought &#8216;Angry Birds&#8217;, 2010&#8242;s top paid for app? Among other apps I saw was a &#8216;Halloween Mouth&#8217; selling for 99¢&#8211;it&#8217;s a picture of a mouth you hold up to your face. (How long would that take to create?) Another popular app is not one, <em>but several</em>, that make farting sounds&#8211;with prices ranging from free to $1.99.</p>
<blockquote><p>
<strong>Latest Update on Flex&#8217;s Fate!</strong>: Because so many questions about Flex were asked (e.g. Is this the end of Flex?) Adobe posed the following:</p>
<p><a href="http://blogs.adobe.com/flex/2011/11/your-questions-about-flex.html">Adobe settles concerns about Flex and Flash.</a></p>
</blockquote>
<p>Now let&#8217;s say, that you create a simple app using a Factory Method. You&#8217;ve got 10 billion units out there. We&#8217;ll say that you have a &#8216;Sneezing App&#8217; that makes different sneezing sounds, and it sells for 99¢. If just 1% of 1% of 1% of 1% of 1% of 1% bought your app, that&#8217;s $10,000&#8211;a half million Indian rupees. If 1 person in 10,000 bought that app, you&#8217;d be a millionaire. (The good thing about language-independent apps like the &#8216;Halloween Mouth&#8217; and &#8216;Fart Factory&#8217; is that they are language independent.)</p>
<blockquote><p>20 Billion Mobile Connected Devices Can&#8217;t Be Wrong!</p></blockquote>
<p>I have no idea how many people will be using PCs as we know them. Maybe they&#8217;ll go the way of the 5 1/4 inch floppy and all we&#8217;ll have is some kind of tablet that we can connect up to the Internet. Development may be done with apps that we rent from a cloud. What is important and key now and later are mobile devices. At this point in time very few Web developers are actively developing apps for mobile devices, and tools like AIR for iOS, Android and Blackberry provide us with a key opportunity.</p>
<p>So, you can be certain that Adobe did not bow out of the Flash-Player-in-the-Mobile-Browser market because they thought it was not going to be a huge market. Look for Dreamweaver to be optimized for HTML5 and some HTML5 development tools. <em>The development tool </em>from Adobe for mobile, though, will be Flash Builder and Flash Pro working with AIR.</p>
<p><strong>A Browser/AIR Mobile Strategy</strong></p>
<p>Keeping in mind that I have nothing against HTML5 and it&#8217;s ability to do many things Flash has done for years—Canvas features some great elements and attributes—let&#8217;s look at a new strategy for development in Flash (including AS3 and the different flavors of AIR).</p>
<p>First off, if you&#8217;ve done much with with mobile browsers, you must have learned they have little to offer, and they are a mixed bag of HTML5 implementation. (The non-mobile browsers are an equal mixed bag as far as having implemented HTML5.) It&#8217;s <strong>only</strong> the <em>mobile browsers</em> that Adobe is no longer supporting. Not too many years ago, there were no mobile browsers; so basically, Adobe is doing what it has always done as far as providing a Flash plugin for the browsers on our computers. It&#8217;s just not going to make them for mobile browsers. I developed several apps for iOS, and while most have been simple and small, I was able to use the same programming structures I did for &#8220;regular&#8221; AS3.</p>
<p>Second, Adobe has been making big strides with Flash Builder and Flash Professional in creating AIR tools for working with mobile devices. This allows us to create ActionScirpt 3.0 apps for mobile devices—forget Web pages. Imagine knocking together an app that does something useful (like calculating the best point in relationship to a parabolic mirror to place a kettle to boil water) that can be used worldwide. Or even a game using some of the little structures we&#8217;ve been developing and discussing on this blog that you can sell for 99¢ (or more!). So quit thinking of yourself as just a &#8220;Web site developer/designer.&#8221; <em>You&#8217;re an app developer/designer</em>.</p>
<p><strong>Everyone Runs to HTML5! Not!</strong></p>
<p>Earlier this year I wrote a book (<em>Smashing HTML5</em>) published by Wiley, and one of the chores I encountered was testing the examples against several different browsers, including mobile ones. There was not a lot of compatibility, and most mobile browsers  were successful with only a small subset of the HTML5 elements. Over time, let&#8217;s hope this improves because if it doesn&#8217;t we&#8217;ll enter the Second Dark Age of incompatible browsers.</p>
<p>In order to get most of the cooler stuff to work, you need either JavaScript or PHP, and so I included chapters on both. (PHP seems to be more compatible for all browsers than anything else&#8211;probably because of the simpler subset of HTML it generates.) I added as much OOP to both as possible, and some of the reviewers didn&#8217;t like the fact that it was not more oriented to the DOM or that I didn&#8217;t use more procedural examples in the PHP/JavaScript section. What I was trying to do was to write an HTML5 book for 2011 and not 2001, which meant that I used several examples of dealing with a mobile environment. Further, some OOP in JavaScript/PHP is a good thing; so I hope that will move some folks towards structure in both JavaScript and PHP.</p>
<p>However, without Flash in the mix, creating Web apps and pages is frustrating, not because JavaScript and PHP aren&#8217;t good programming tools but rather because of browser incompatibility.  I&#8217;ve got a feeling that to effectively use HTML5 and all of the related CSS3, developers are going to be spending a lot of JavaScript code determining which browser is being used and making the appropriate accommodations. Who wants to sub-code for every possible browser? This includes mobile browsers.  My hunch is that they&#8217;ll all head for the lowest common denominator, which is probably one of the mobile browsers that is just slightly better than HTML4.</p>
<p>So, I&#8217;ve started thinking &#8220;Build an App; Not a Web Page.&#8221; Let&#8217;s hear your thoughts on Adobe&#8217;s decisions.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2011%2F11%2Factionscript-design-patterns-transcend-changes-at-adobe%2F&amp;title=ActionScript%20Design%20Patterns%20Transcend%20Changes%20at%20Adobe" id="wpa2a_4"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2011/11/actionscript-design-patterns-transcend-changes-at-adobe/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>ActionScript 3.0 Design Patterns and iOS:  A New Home for Apps</title>
		<link>http://www.as3dp.com/2011/08/actionscript-3-0-design-patterns-and-ios-a-new-home-for-apps/</link>
		<comments>http://www.as3dp.com/2011/08/actionscript-3-0-design-patterns-and-ios-a-new-home-for-apps/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 13:42:26 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Decorator]]></category>
		<category><![CDATA[Factory Method]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=6123</guid>
		<description><![CDATA[It&#8217;s Easy Once You Get Your Certificate and Provisioning Profile Having finally got my magical combination of permissions set up just so, the process began coming fairly easily. The problem is not Adobe, but rather getting the files from Apple just right. Once you get the files, you can use them over an over. One [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_6124" class="wp-caption alignleft" style="width: 330px"><img src="http://www.as3dp.com/wp-content/uploads/2011/08/apps.PNG" alt="Make Your Own Apps with Design Patterns" title="apps" width="320" height="480" class="size-full wp-image-6124" /><p class="wp-caption-text">Make Your Own Apps with Design Patterns</p></div><strong>It&#8217;s Easy Once You Get Your  Certificate and Provisioning Profile</strong></p>
<p>Having finally got my magical combination of permissions set up just so, the process began coming fairly easily. The problem is not Adobe, but rather getting the files from Apple just right. Once you get the files, you can use them over an over. One is a certificate file with a .p12 extension, and the other is a provisioning file. It looks like a lot of people are having the same problem because when I finally found a <a href="http://stackoverflow.com/questions/999313/iphone-app-signing-a-valid-signing-identity-matching-this-profile-could-not-be-f">solution on the Web at StackOverflow</a> several other developers indicated (with heart-felt thanks) that they were encountering the same problem. (The solution that worked for me was to start over and delete all provisioning profiles and login keychain.)  So if you got your Apple iOS Developer ticket ($99 or free to University students/faculty), that&#8217;s just the first part. The next part is to hook up your iOS device (mine is a 3S iPhone) and using the Xcode development tools, go through a process that generates the files you need. The following image shows what these little gems look like. If you put those two files in with your AIR iOS files, it&#8217;s a piece of cake. (Go ahead and download the files as well.) <div id="attachment_6127" class="wp-caption alignleft" style="width: 259px"><img src="http://www.as3dp.com/wp-content/uploads/2011/08/FigA.png" alt="Same files can be used with different apps" title="FigA" width="249" height="102" class="size-full wp-image-6127" /><p class="wp-caption-text">Same files can be used with different apps</p></div><br />
<a href="http://www.mwd.hartford.edu/mwd11/downloads/MWDdownloads.php" target="_blank"><img src="http://www.as3dp.com/wp-content/uploads/2009/11/kilroy.png" alt="kilroy" title="kilroy" width="112" height="56" class="alignnone size-full wp-image-2020" /></a></p>
<p><a href="http://developer.apple.com/devcenter/ios/index.action">Apple provides videos and a whole slew of tools and aids</a>, and if you follow the instructions, you should be able to develop the right files. (Sad experience had led me to suggest that you take your time and follow instructions carefully.) Anyway, whether you get the certificate and provisioning files on the first time or whether you struggle like I did, once you&#8217;ve got them; they&#8217;re good for about four months. You can develop on either a Mac or Windows PC and re-use the same files on different apps. (I haven&#8217;t gone through the process that Apple has for getting an app in the App Store; so you&#8217;re on your own in that department.)  The image on the right is a screenshot taken with an iPhone:<div id="attachment_6134" class="wp-caption alignright" style="width: 260px"><img src="http://www.as3dp.com/wp-content/uploads/2011/08/cartoonVG.png" alt="Animated tween, text and graphic" title="cartoonVG" width="250" height="375" class="size-full wp-image-6134" /><p class="wp-caption-text">Animated tween, text and graphic</p></div></p>
<p><strong>Step-By-Step</strong></p>
<p>This section walks you through the process of working with a Flash Pro project set up for use with iOS. In the previous post on iOS, the sample project was to create banners that can be used in a Factory Method context by loading external .SWF files. On the iPhone, that didn&#8217;t work.  The problem seemed to be the mobile device&#8217;s inability to grab the external .SWF files even though, the .SWF files were included in the General settings for the Included files window. So, using the same tweens, I created MovieClips and put them in the Flash Pro library and then set them up as classes. Then in the concrete product files, I just instantiated classes with the tweens instead of loading external .SWF files, and the rest of the program was unchanged. (That is where design patterns really shine—easy to make changes.)</p>
<p>Okay, now to step through the process. This was all done using AIR 3.0, Flash Player 11 public betas on a iMac running the new Lion OS.  After you open a new AIR for iOS and write all of your code and add any graphics and text, the first step is to select the FLA file, make sure that nothing is selected on the stage and then click the little wrench icon next to the Player selection where it should indicate &#8216;AIR for iOS.&#8217; That will open the AIR for iOS Settings window as shown in Figure 1:<br />
<div id="attachment_6142" class="wp-caption alignnone" style="width: 510px"><img src="http://www.as3dp.com/wp-content/uploads/2011/08/Fig1.png" alt="&lt;em&gt;&lt;strong&gt;Figure 1:&lt;/strong&gt; General Settings of AIR for iOS&lt;/em&gt;" title="Fig1" width="500" height="694" class="size-full wp-image-6142" /><p class="wp-caption-text"><em><strong>Figure 1:</strong> General Settings of AIR for iOS</em></p></div></p>
<p>For getting started, choose Full screen instead of Auto orientation. Use the CPU for the Rendering processor, specify your device and choose the Standard resolution. The included files will be an .SWF and .XML file. Leave those alone, and for this app, you do not need to add any others.</p>
<p>For this next step, you&#8217;ll need both the certificate and provisioning files in the same folder with the other class files.  So if you haven&#8217;t created those files and linked them to the device you&#8217;re testing it on; do so now. The click the Deployment button next to the General button at the top of the AIR for iOS Settings window. Figure 2 shows the deployment settings:<br />
<div id="attachment_6155" class="wp-caption alignnone" style="width: 510px"><img src="http://www.as3dp.com/wp-content/uploads/2011/08/Fig2.png" alt="&lt;em&gt;&lt;strong&gt;Figure 2:&lt;/strong&gt; Deployment window&lt;/em&gt;" title="Fig2" width="500" height="694" class="size-full wp-image-6155" /><p class="wp-caption-text"><em><strong>Figure 2:</strong> Deployment window</em></p></div></p>
<p>The password for the certificate is the one you entered when you created the certificate—not one associated with your computer. Use the search folder to find your Provisioning profile file.  The App ID is the name you gave your initial FLA file—I&#8217;m in the habit of calling all of mine &#8220;Client,&#8221; but now I&#8217;ve got to think about what users will see on their mobile device..</p>
<p>This post does not get into the iOS deployment beyond the local development stage. So, select the &#8220;Quick publishing for device testing&#8221; or &#8220;Quick publishing for device debugging.&#8221; I selected the former because I chose to do the debugging using the standard Flash tools. After all I went through to get the certificate and mobile provision files to work right, I wasn&#8217;t about to tempt fate just yet and do more than the minimum.</p>
<p>This final step is fun. You can easily create your own iOS icon. Here&#8217;s what you need to do to get started:</p>
<ol>
<li>Create a square image with your logo or some symbol  you want to use to identify you application. Save it as a .PNG file. (In the image at the top of this post, you can see the two application icons using the Sandlight logo.) Be sure that the image has equal width and height.</li>
<li>Save three images in sizes 29 pixel square, 57 pixel square and 512 pixel square. Depending on the mobile device, you may want to create other sizes as well.  I started off with the Adobe Illustrator version and saved each size as a PNG file.</li>
<li>Place the three image files in a folder named &#8220;icons&#8221; and place the icons folder in the directory where you are creating your mobile app.</li>
</ol>
<p>In Figure 3, you can see the preview window showing the image used for the application described in this post.</p>
<div id="attachment_6158" class="wp-caption alignnone" style="width: 510px"><img src="http://www.as3dp.com/wp-content/uploads/2011/08/Fig3.png" alt="&lt;em&gt;&lt;strong&gt;Figure 3:&lt;/strong&gt; Assigning icons for app image</em>&#8221; title=&#8221;Fig3&#8243; width=&#8221;500&#8243; height=&#8221;694&#8243; class=&#8221;size-full wp-image-6158&#8243; /><p class="wp-caption-text"><em><strong>Figure 3:</strong> Assigning icons for app image</strong></p></div>
<p></em>Be sure to click each icon size for each of the three sizes and load the URL (icons/iconXX.png) before you click OK. Note also that two of the icons are settings for iPads, and so if you have an iPad, create image files for those as well.</p>
<p><strong>Installing your iOS on your Mobile Device</strong></p>
<p>Now you&#8217;re set to Publish your files required for an iOS mobile app. When you click &#8220;Publish&#8221; you will find that it takes a while to process everything. Once you&#8217;re finished, you will see all the files generated for your iOS device. Figure 4 shows the files you will see—including the all-important .IPA file.<br />
<div id="attachment_6165" class="wp-caption alignnone" style="width: 510px"><img src="http://www.as3dp.com/wp-content/uploads/2011/08/folder.png" alt="&lt;em&gt;&lt;strong&gt;Figure 4:&lt;/strong&gt; Files used and generated&lt;/em&gt;" title="folder" width="500" height="305" class="size-full wp-image-6165" /><p class="wp-caption-text"><em><strong>Figure 4:</strong> Files used and generated</em></p></div></p>
<p>As you can see in Figure 4, one of the files is named <strong>BannerFactory.ipa</strong>. That is the file that will install your app onto your iOS mobile device. Connect your iPhone or iPad or iWhatever that runs on iOS, and double-click the IPA file and it will upload your app into the iTunes Apps folder.  (On your iTunes, click <strong>Apps</strong> in the LIBRARY folder, and you should see your new application as shown in Figure 5.)</p>
<div id="attachment_6167" class="wp-caption alignnone" style="width: 510px"><img src="http://www.as3dp.com/wp-content/uploads/2011/08/Fig5.png" alt="&lt;em&gt;&lt;strong&gt;Figure 5:&lt;/strong&gt; iTunes Apps folder&lt;/em&gt;" title="Fig5" width="500" height="252" class="size-full wp-image-6167" /><p class="wp-caption-text"><em><strong>Figure 5:</strong> iTunes Apps folder</em></p></div>
<p>If you see your application icon and file, you&#8217;ve been successful—up to this point. The last step is to install your app onto your mobile device. The final step is to select your device and then check your application Sync. Figure 6 shows  iTunes with your application selected (checkbox) and ready for Sync.</p>
<div id="attachment_6169" class="wp-caption alignnone" style="width: 510px"><img src="http://www.as3dp.com/wp-content/uploads/2011/08/Fig6.png" alt="&lt;em&gt;&lt;strong&gt;Figure 6&lt;/strong&gt;App set for installing in iPhone&lt;/em&gt;" title="Fig6" width="500" height="252" class="size-full wp-image-6169" /><p class="wp-caption-text"><em><strong>Figure 6:</strong> App set for installing in iPhone</em></p></div>
<p>Note in Figure 6 that the iOS device is selected under DEVICES in the left panel and that the new application (BannerFactory) has a check next to it. Click the Sync button (or Apply and then Sync) and if you have your device properly identified, you will see your icon and app on your mobile device.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2011%2F08%2Factionscript-3-0-design-patterns-and-ios-a-new-home-for-apps%2F&amp;title=ActionScript%203.0%20Design%20Patterns%20and%20iOS%3A%20%20A%20New%20Home%20for%20Apps" id="wpa2a_6"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2011/08/actionscript-3-0-design-patterns-and-ios-a-new-home-for-apps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Warrior&#039;s New Clothes: Using AS3 in Flash Builder to Create Sprite Graphic Classes</title>
		<link>http://www.as3dp.com/2011/06/the-warriors-new-clothes-using-as3-in-flash-builder-to-create-sprite-graphic-classes/</link>
		<comments>http://www.as3dp.com/2011/06/the-warriors-new-clothes-using-as3-in-flash-builder-to-create-sprite-graphic-classes/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 14:44:00 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Beginner's Guide]]></category>
		<category><![CDATA[Decorator]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=5750</guid>
		<description><![CDATA[Sprite Classes in Code When I&#8217;m working on an example, I&#8217;ll use a combination of Flash Pro and Flash Builder. However, using Flash Pro, all of my drawings are in the Flash Library and may not be accessible to Flash Builder users. Besides, my drawings are pretty simple composed of basic shapes—rectangles, circles and triangles. [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_5749" class="wp-caption alignleft" style="width: 260px"><img src="http://www.as3dp.com/wp-content/uploads/2011/06/armor.png" alt="Code your own Sprite classes" title="armor" width="250" height="250" class="size-full wp-image-5749" /><p class="wp-caption-text">Code your own Sprite classes</p></div><strong>Sprite Classes in Code</strong></p>
<p>When I&#8217;m working on an example, I&#8217;ll use a combination of Flash Pro and Flash Builder. However, using Flash Pro, all of my drawings are in the Flash Library and may not be accessible to Flash Builder users. Besides, my drawings are pretty simple composed of basic shapes—rectangles, circles and triangles. These images are transformed into Sprite classes in the Symbol Editor of Flash Pro, and the type is changed from the default MovieClip to Sprite. If I coded the images as Sprites using ActionScript 3.0, the Flash Builder users would be able to more easily use them and the Flash Pro users could use them with equal ease.</p>
<p>Let&#8217;s face it, my graphics are not going to get any better whether I code them or draw them; so why not code them? So that&#8217;s what I&#8217;ve done. In the <a href="http://www.as3dp.com/2011/06/14/well-armored-warrior-decorator-for-beginners/">previous post on the Decorator design pattern for beginners</a>, I had three graphic &#8220;armor&#8221; pieces that were used with concrete decorator classes. All I&#8217;ve done for this mini-post is to provide the &#8220;armor&#8221; sprites as pure code. From now on when I have a Sprite image, I&#8217;ll just code them up in ActionScript 3.0 as Sprite classes and make it easy for everyone. Here&#8217;s the Shield, BodyArmor and Helmet classes: (Next page.)<br />
<span id="more-5750"></span><br />
<strong>Shield</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5750code8'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57508"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p5750code8"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Shape</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Shield <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> shield:Shape = <span style="color: #000000; font-weight: bold;">new</span> Shape<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Shield<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			shield.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,0x0066ff<span style="color: #66cc66;">&#41;</span>;
			shield.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0x0033ff,.50<span style="color: #66cc66;">&#41;</span>;
			shield.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawCircle</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">30</span>,<span style="color: #cc66cc;">31.25</span><span style="color: #66cc66;">&#41;</span>;
			graphics.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>shield<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p><strong>Body Armor</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5750code9'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p57509"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p5750code9"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Shape</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BodyArmor <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bodyArmor:Shape = <span style="color: #000000; font-weight: bold;">new</span> Shape<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> BodyArmor<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			bodyArmor.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,0x990000<span style="color: #66cc66;">&#41;</span>;
			bodyArmor.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0x999999,.50<span style="color: #66cc66;">&#41;</span>;
			bodyArmor.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawTriangles</span><span style="color: #66cc66;">&#40;</span>Vector.<span style="color: #66cc66;">&lt;</span>number<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">116</span>,<span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">58</span>,<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			bodyArmor.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>bodyArmor<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p><strong>Helmet</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p5750code10'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p575010"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p5750code10"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Shape</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Helmet <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> helmet:Shape = <span style="color: #000000; font-weight: bold;">new</span> Shape<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Helmet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			helmet.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xcc0000<span style="color: #66cc66;">&#41;</span>;
			helmet.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">moveTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">25</span><span style="color: #66cc66;">&#41;</span>;
			helmet.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">curveTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span>, -<span style="color: #cc66cc;">20</span>, <span style="color: #cc66cc;">60</span>, <span style="color: #cc66cc;">25</span><span style="color: #66cc66;">&#41;</span>;
			helmet.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			helmet.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,0x996600<span style="color: #66cc66;">&#41;</span>;
			helmet.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">moveTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">25</span><span style="color: #66cc66;">&#41;</span>;
			helmet.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>helmet<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>I realize that this is pretty simple stuff, but if it helps beginners working with OOP and classes, not to mention design patterns, it&#8217;s worth it. Now, all that you have to do is to create the Warrior!!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2011%2F06%2Fthe-warriors-new-clothes-using-as3-in-flash-builder-to-create-sprite-graphic-classes%2F&amp;title=The%20Warrior%26%23039%3Bs%20New%20Clothes%3A%20Using%20AS3%20in%20Flash%20Builder%20to%20Create%20Sprite%20Graphic%20Classes" id="wpa2a_8"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2011/06/the-warriors-new-clothes-using-as3-in-flash-builder-to-create-sprite-graphic-classes/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>The Vote is In!</title>
		<link>http://www.as3dp.com/2011/03/the-vote-is-in/</link>
		<comments>http://www.as3dp.com/2011/03/the-vote-is-in/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 09:28:24 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=5047</guid>
		<description><![CDATA[Monday we&#8217;ll start a new series for beginners in OOP and Design Patterns using ActionScript 3.0. The series will include examples from both Flex (Flash Builder) and Flash (Flash Professional.) The vote wasn&#8217;t even close, but because we believe that concurrent programming (parallel programming, multi-threaded programming) is so crucial to the future of both ActionScript [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.as3dp.com/wp-content/uploads/2011/03/Results.png" alt="Results" title="Results" width="250" height="188" class="alignleft size-full wp-image-5053" />Monday we&#8217;ll start a new series for beginners in OOP and Design Patterns using ActionScript 3.0. The series will include examples from both Flex (Flash Builder) and Flash (Flash Professional.) The vote wasn&#8217;t even close, but because we believe that concurrent programming (parallel programming, multi-threaded programming) is so crucial to the future of both ActionScript 3.0 and programming in general, we&#8217;ll be issuing posts on those as well. In the same polling, there were requests for combo patterns, frameworks, and even one for MVC, but for the time being, we&#8217;ll be developing a series for beginners and I&#8217;d like to make a run at creating a virtual machine for doing concurrent programming in ActionScript.</p>
<p>However, since we agreed to let you decide, our next post will be to get those who are beginning, intermediate and advanced programmers through the worm hole and into the land of OOP and Design Patterns.</p>
<p>In the meantime ponder this: <em>C’est magnifique, mais ce n’est pas la guerre. C’est de la folie.</em> That&#8217;s how the new series begins.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2011%2F03%2Fthe-vote-is-in%2F&amp;title=The%20Vote%20is%20In%21" id="wpa2a_10"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2011/03/the-vote-is-in/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>It&#039;s the Client: Not the Main!</title>
		<link>http://www.as3dp.com/2010/09/its-the-client-not-the-main/</link>
		<comments>http://www.as3dp.com/2010/09/its-the-client-not-the-main/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 18:18:59 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=3602</guid>
		<description><![CDATA[Let&#8217;s Stop Calling the Client &#8220;Main&#8221; At one time using Flex, it automatically generated a first file it named &#8220;main&#8221; and everywhere I look I see the client class named &#8220;Main.&#8221; Why? Naming a class that does nothing but make requests &#8220;main&#8221; is like calling the butler the &#8216;Lord of the Manor&#8217; because he answers [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.as3dp.com/wp-content/uploads/2010/09/main.png" alt="main" title="main" width="250" height="205" class="alignleft size-full wp-image-3604" /><strong>Let&#8217;s Stop Calling the Client &#8220;Main&#8221;</strong><br />
At one time using Flex, it automatically generated a first file it named &#8220;main&#8221; and everywhere I look I see the client class named &#8220;Main.&#8221; Why? Naming a class that does nothing but make requests  &#8220;main&#8221; is like calling the butler the &#8216;Lord of the Manor&#8217; because he answers the door. In addition, it&#8217;s a little confusing because the design pattern is the main part, and that&#8217;s important to fix that idea in your head. I think there were even a few places in the Gang of Four book where they use &#8220;main&#8221; in a class that was anything but that. In discussing participants in a design pattern, you will generally find either a reference to the Client or the Client as an actual part of the design pattern. You will never see &#8220;Main&#8221; as a design pattern participant.</p>
<p>Everything in your life will get better if you drop naming classes &#8220;Main.&#8221; I even made a class diagram of the point as shown in Figure 1.<br />
<div id="attachment_3603" class="wp-caption alignnone" style="width: 510px"><img src="http://www.as3dp.com/wp-content/uploads/2010/09/MainCli.png" alt="&lt;em&gt;&lt;strong&gt;Figure 1:&lt;/strong&gt;Why to Quit Calling the Client Main&lt;/em&gt;" title="MainCli" width="500" height="256" class="size-full wp-image-3603" /><p class="wp-caption-text"><em><strong>Figure 1:</strong>Why to Quit Calling the Client Main</em></p></div></p>
<p>So let&#8217;s focus on design patterns and use names that describe the roles. The term &#8220;main&#8221; is a tradition, but programming is not<em> Fiddler on the Roof</em>; so we can cut it out!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2010%2F09%2Fits-the-client-not-the-main%2F&amp;title=It%26%23039%3Bs%20the%20Client%3A%20Not%20the%20Main%21" id="wpa2a_12"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2010/09/its-the-client-not-the-main/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>AS3 Design Patterns now on iPhone!</title>
		<link>http://www.as3dp.com/2009/11/as3-design-patterns-now-on-iphone/</link>
		<comments>http://www.as3dp.com/2009/11/as3-design-patterns-now-on-iphone/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 19:13:35 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=2050</guid>
		<description><![CDATA[We were delighted to hear that our book was selected by O&#8217;Reilly to be among the first to be made available for the iPhone! If you click on the App Store icon (located just below the picture of the book&#8217;s cover), it&#8217;ll take you right to the store. Check out the tweet on our MicroBlog [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_2068" class="wp-caption alignnone" style="width: 490px"><img src="http://www.as3dp.com/wp-content/uploads/2009/11/iphone2.png" alt="ActionScript 3.0 Design Patterns for the iPhone" title="iphone2" width="480" height="421" class="size-full wp-image-2068" /><p class="wp-caption-text">ActionScript 3.0 Design Patterns for the iPhone</p></div>
<p>We were delighted to hear that our book was selected by O&#8217;Reilly to be among the first to be made available for the iPhone! If you click on the <strong>App Store icon</strong> (located just below the picture of the book&#8217;s cover), it&#8217;ll take you right to the store. Check out the tweet on our MicroBlog to see iPhone application with our book. Or just open iTunes and search for &#8220;O&#8217;Reilly Design Patterns&#8221; and there it is. Even better, it&#8217;s only $4.99, and you can have it handy wherever you and your iPhone or touch-pad iPod go. (Now if Bill can only figure out a way to get an iPhone&#8230;)</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2009%2F11%2Fas3-design-patterns-now-on-iphone%2F&amp;title=AS3%20Design%20Patterns%20now%20on%20iPhone%21" id="wpa2a_14"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2009/11/as3-design-patterns-now-on-iphone/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>100 Posts of ActionScript 3.0 Design Patterns: A Retrospective</title>
		<link>http://www.as3dp.com/2009/09/100-posts-of-actionscript-30-design-patterns-a-retrospective/</link>
		<comments>http://www.as3dp.com/2009/09/100-posts-of-actionscript-30-design-patterns-a-retrospective/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 01:06:53 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=1555</guid>
		<description><![CDATA[What&#8217;s 100 Posts? Here we are at 100 posts already since we started our humble blog in 2007. Our original goal was simply to cover the design patterns that didn&#8217;t fit in our book and try to generate a discussion among ActionScript 3.0 developers about OOP and design patterns. However, we ended up going in [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_1600" class="wp-caption alignleft" style="width: 166px"><img class="size-full wp-image-1600" title="billblogslim" src="http://www.as3dp.com/wp-content/uploads/2009/09/billblogslim.png" alt="Bill" width="156" height="229" /><p class="wp-caption-text">Bill</p></div>
<div id="attachment_1601" class="wp-caption alignright" style="width: 174px"><img class="size-full wp-image-1601" title="chandimaslim" src="http://www.as3dp.com/wp-content/uploads/2009/09/chandimaslim.png" alt="Chandima" width="164" height="229" /><p class="wp-caption-text">Chandima</p></div>
<p><strong>What&#8217;s 100 Posts?</strong></p>
<p>Here we are at 100 posts already since we started our humble blog in 2007. Our original goal was simply to  cover the design patterns that didn&#8217;t fit in our book and try to generate a discussion among ActionScript 3.0 developers about OOP and design patterns. However, we ended up going in several different directions and learned a lot (mostly from our readers) at every turn. Here&#8217;s a summary list:</p>
<ul>
<li>Completed all of the original design patterns</li>
<li>Introduced PureMVC in ActionScript 3.0</li>
<li>Created Posts and Tools for OOP Principles</li>
<li>Started OOP for Artists Series</li>
<li>Launched Lunch Bucket Series: Take a Design Pattern to Work</li>
<li>Began Golden Lunch Bucket Contests and World Cup</li>
<li>Established the Closer Look Series for idiosyncratic topics</li>
<li>Lively Discussions (aka <em>Brawls</em>) About Contentious Topics</li>
<li>Generated best group of readers of any blog</li>
</ul>
<p>We found that our readers are far more diverse than thought. Originally, we expected advanced and intermediate ActionScript 3.0 developers with fairly hefty programming backgrounds. However, we also found that some very smart people who were beginners at programming found their way to our site. Further, they were interested in learning ActionScript 3.0 using OOP structures. We were most gratified to find that comments from the advanced readers were directed at the less experienced in supportive and helpful ways.</p>
<p><strong>What should we write about?</strong></p>
<p>Instead of doing periodic polling, we are trying out a new ongoing feedback feature. See the new <em>What should we write about </em>widget in the center column? Type in new topic suggestions or vote on existing ones by clicking on the <strong>green button </strong>with the <em>plus</em> icon. You can also <a href="http://skribit.com/blogs/as3dp" target="_blank">comment on suggestions already made</a>.</p>
<p><strong>In memorium</strong></p>
<p>The cat in my simpsonized photo is in memory of my longtime pet of 15 years who was euthanized this Monday. She was suffering from liver and kidney failure. Although in pain, she remained a <a title="Natty on her last day." rel="lightbox" href="http://www.as3dp.com/wp-content/uploads/2009/09/natty.jpg">loving kitty until the very end</a>.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2009%2F09%2F100-posts-of-actionscript-30-design-patterns-a-retrospective%2F&amp;title=100%20Posts%20of%20ActionScript%203.0%20Design%20Patterns%3A%20A%20Retrospective" id="wpa2a_16"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2009/09/100-posts-of-actionscript-30-design-patterns-a-retrospective/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>OOP for Artists: The Empowerment of ActionScript 3.0</title>
		<link>http://www.as3dp.com/2009/09/oop-for-artists-the-empowerment-of-actionscript-30/</link>
		<comments>http://www.as3dp.com/2009/09/oop-for-artists-the-empowerment-of-actionscript-30/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 02:26:18 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[OOP for Artists]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=1496</guid>
		<description><![CDATA[In a recent post I voiced my admiration for artists, designers and animators but noted that they seem to have been left out in the cold with ActionScript 3.0. I added a little helper statement not in the ActionScript 3.0 documentation—MovieClip.addFrameScript(). The idea was to encourage artists not to be too hasty in giving up [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.as3dp.com/wp-content/uploads/2009/09/ooprosie150.png" alt="OOP for Artists" title="OOP for Artists" width="150" height="194" class="alignleft size-full wp-image-1627" /></p>
<p> In a <a href="http://www.as3dp.com/2009/08/25/artists-animators-and-actionscript-30/">recent post I voiced my admiration for artists</a>, designers and animators but noted that they seem to have been left out in the cold with ActionScript 3.0. I added a little <em>helper statement</em> not in the ActionScript 3.0 documentation—<strong>MovieClip.addFrameScript()</strong>. The idea was to encourage artists not to be too hasty in giving up on coding altogether.</p>
<p>Quite frankly, I was surprised by the number of comments we received on that post. I didn&#8217;t think artists bothered with our kind of discussions, and was more than a little  gratified to find that some of our readers identified with the issues discussed. So  I started thinking about a series of posts for helping artists.</p>
<p>I didn&#8217;t want to do a &#8220;dumbed down&#8221; ActionScript 3.0 for artists; so I opted for an approach that would cover the same principles that we&#8217;ve discussed throughout the life of this blog. However, I would move more deliberately and touch more bases—especially the basics of OOP. Further, I decided to use video and take advantage of the new Quicktime Player that comes with Screen Sharing. So, I created a simple class to start things off, and put it in an .f4v file (H.264 format) and you can download it by clicking the download button: <a href="http://nemo.mwd.hartford.edu/~wsanders/oopart/"><br />
<img src="http://www.as3dp.com/wp-content/uploads/2009/09/smalldownload.jpg" alt="smalldownload" title="smalldownload" width="150" height="50" class="alignnone size-full wp-image-1908" /><br />
</a> You will need an <a href="http://www.adobe.com/products/mediaplayer/">Adobe Media Player</a> that is free to download. I did not include any .fla files because I&#8217;d have to put in at least two because some have  CS3 and others CS4; so you&#8217;ll have to use your own .fla files. Each video is short and will play full screen using the Adobe Media Player. The only thing I need is feedback to let me know whether this kind of thing is helpful or not. I will be focusing on graphics and loading graphics, but I welcome ideas from one and all.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2009%2F09%2Foop-for-artists-the-empowerment-of-actionscript-30%2F&amp;title=OOP%20for%20Artists%3A%20The%20Empowerment%20of%20ActionScript%203.0" id="wpa2a_18"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2009/09/oop-for-artists-the-empowerment-of-actionscript-30/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Artists, Animators and ActionScript 3.0</title>
		<link>http://www.as3dp.com/2009/08/artists-animators-and-actionscript-30/</link>
		<comments>http://www.as3dp.com/2009/08/artists-animators-and-actionscript-30/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 21:44:25 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=1380</guid>
		<description><![CDATA[Artists and Graphic Designers For me, graphic designers and artists are angels. No matter how I try, I can only get so far in graphic design. Tools like clip art, templates, and Kuler help me achieve not awful , but that’s it. (I can even screw up clip art.) So, for anything serious, I’ve got [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Artists and Graphic Designers</strong></p>
<p><img src="http://www.as3dp.com/wp-content/uploads/2009/08/designer-295x300.png" alt="designer" title="designer" width="295" height="300" class="alignleft size-medium wp-image-1381" /></p>
<p>For me, graphic designers and artists are angels. No matter how I try, I can only get so far in graphic design. Tools like clip art, templates, and Kuler help me achieve <em>not awful </em>, but that’s it. (I can even screw up clip art.) So, for anything serious, I’ve got to work with graphic artists.  That’s no problem—I like working with angels.</p>
<p>Some graphic artist have made the transition to some version of ActionScript, but with ActionScript 3.0 most complained that they were getting left behind. Early Flash had few ActionScript options and a system for entering code that didn’t require any programming background at all. With ActionScript 2.0, things got better for developers, but designers started voicing concern over increased complexity. With ActionScript 3.0 and the loss of the ability to put code into buttons and MovieClip objects directly, some graphic artists became furious with Flash over what they saw as a betrayal. It was like a carload of kids on the way to do something fun ditched the artists and designers on the roadside.<br />
<span id="more-1380"></span><br />
Other than a handful of developer/designers, most designers aren’t going to become competent with ActionScript 3.0, let alone OOP or design patterns—just like I’m never going to be a competent designer or artist. So I was thinking an interesting project for this blog would be to develop some “Clip Code” for artists. However, I’m not sure what kind of code they’d need. Most of the “Clip Art” that I use is from photographs, but while I know the kind of artwork I need, I don’t know what kind code graphic designers need.</p>
<p>In the same way that I don’t want to have shoddy graphics or photographs (I can do that myself), the “Clip Code” I have in mind is grounded in good but simple design patterns and OOP that artists can use. So, I’d like to throw that one out to the readers of this blog for ideas of what would be useful to graphic designers.</p>
<p><strong>Animation and Dante’s 10th Circle of ActionScript Hell</strong></p>
<p>We all remember from our Italian Literature course that Dante Alighieri’s <em>Divine Comedy</em> describes hell as having nine circles—the last circle being reserved for treason. Were Dante an ActionScript developer, he’d have a 10th Circle for those animators who spread 50 little ActionScript code blocks all over the timeline in different frames and on different layers. (In the last mention of Dante’s inferno on this blog, we only got to the 9th circle.)</p>
<p><img src="http://www.as3dp.com/wp-content/uploads/2009/08/animator-295x300.png" alt="animator" title="animator" width="295" height="300" class="alignleft size-medium wp-image-1382" /></p>
<p>Don’t get me wrong. I love animation, and in fact I got Flash initially so that I could do animations on the Web. When first working with Flash, I ran out and got Tony White’s <em>The Animator’s Workbook: Step-by-Step Techniques of Drawn Animation</em>, and I was delighted with what Flash could do following traditional animation techniques. (Joe Cartoon is still one of my heroes.)</p>
<p>What drives me nuts is using animations for some little effect that will be forgotten after one or two views that screw up an entire application. I’m convinced that animation is the <em>sine qua non</em> of Flash, and so I would never suggest that it be reduced in any way. Rather, I think that animation in movie clips needs to be controlled outside of the confines of code embedded in frames and the timeline. For example, pressing the green Play button shows a simple movie clip added to an existing fire-the-weapon animation:</p>
<p><a href="http://www.sandlight.net/testBench/weapon/"  target="_blank"><br />
<img src="http://www.as3dp.com/wp-content/uploads/2009/07/play.png" alt="play" title="play" width="99" height="47" class="alignnone size-full wp-image-1257" /><br />
</a></p>
<p>The relevant code for the operation is the following:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1380code12'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p138012"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
</pre></td><td class="code" id="p1380code12"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Sound</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #006600;">SoundChannel</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLRequest</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Client <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> m249:<span style="color: #0066CC;">MovieClip</span>=<span style="color: #000000; font-weight: bold;">new</span> M249<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> mc:<span style="color: #0066CC;">MovieClip</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> weapon:SoundChannel;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">url</span>:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;M249.mp3&quot;</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Client<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			m249.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>,fireWeapon<span style="color: #66cc66;">&#41;</span>;
			m249.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">50</span>,m249.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">60</span>;
			addChild<span style="color: #66cc66;">&#40;</span>m249<span style="color: #66cc66;">&#41;</span>;
			m249.<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> fireWeapon<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			playOnce<span style="color: #66cc66;">&#40;</span>m249<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> urlReq:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> gun:<span style="color: #0066CC;">Sound</span>=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Sound</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			gun.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>urlReq<span style="color: #66cc66;">&#41;</span>;
			weapon = gun.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> playOnce<span style="color: #66cc66;">&#40;</span>mc:<span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">mc</span>=mc;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">mc</span>.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">mc</span>.<span style="color: #006600;">addFrameScript</span><span style="color: #66cc66;">&#40;</span>mc.<span style="color: #006600;">totalFrames</span>-<span style="color: #cc66cc;">1</span>,reset<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> reset<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">mc</span>.<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>The  <strong>m249</strong> instance is of a movie clip that uses a shape tween to simulate muzzle flashes. (The sound routine was borrowed from <a href="http://www.as3dp.com/2009/08/19/wrong-way-warrior-getting-flexibility-with-design-patterns—part-ii/">another application</a>.)</p>
<p>Initially, the problem I encountered, and I am sure all Flash animators encounter, is the requirement of keeping at least <em>some code</em> on the timeline. After a few false starts, I was able to control it with relatively simple functions with <em>no timeline code</em>. The above code simply represents the possibility of allowing animators to do whatever they want while not worrying about code.</p>
<p>Thanks to Steve Mathews and Colin Holgate who introduced me to the undocumented <strong>MovieClip.addFrameScript()</strong>, I was able to stop the looping movie clip after a single iteration. My initial solution used <strong>Event.ENTER_FRAME</strong>, but I liked that offered up by Steve and Colin better. Anyway, there’s a good post on <strong>addFrameScript()</strong> at <a href= "http://troyworks.com/blog/2007/09/22/as3-movieclipaddframescript/"> Troy Gardner’s blog</a> if you’d like to learn more about it. Like all undocumented code, I’m often at a loss to understand why it’s undocumented.</p>
<p>The huge advantage of an approach that is not in anyway tied to the timeline is <em>re-usability</em>. If all of the coding is external to the development of the movie clip with the animation, there’s less worry about getting tangled up in unknown code lurking on the timeline. You can reuse the animating movie clips with the assurance that what you see is what you get and you can add code without tangling it up with code tucked away in some unseen layer on an unseen frame.</p>
<p>For complex animations, planning is essential, and I’d like to find out what animators would find useful included in the examples and projects examined on this blog. Like artist, animators work is some kind of context and I’d like to refactor animations so that <em>no timeline code</em> is included in the application of the animations.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.as3dp.com%2F2009%2F08%2Fartists-animators-and-actionscript-30%2F&amp;title=Artists%2C%20Animators%20and%20ActionScript%203.0" id="wpa2a_20"><img src="http://www.as3dp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.as3dp.com/2009/08/artists-animators-and-actionscript-30/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
	</channel>
</rss>

