<?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; Tools</title>
	<atom:link href="http://www.as3dp.com/category/tools/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 Design Pattern Catalog: Creational Patterns</title>
		<link>http://www.as3dp.com/2009/07/actionscript-30-design-pattern-catalog-creational-patterns/</link>
		<comments>http://www.as3dp.com/2009/07/actionscript-30-design-pattern-catalog-creational-patterns/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 16:14:29 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[Catalog]]></category>
		<category><![CDATA[Factory Method]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=1151</guid>
		<description><![CDATA[A Tale of Two Factories: One New and One Reused This is the first of three posts on the actual AIR ActionScript 3.0 Design Pattern catalog. Previously, I had discussed the thinking that went into the design of the Catalog, and here is the first actual AIR application with the Creational Patterns portion of the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A Tale of Two Factories: One New and One Reused</strong></p>
<p>This is the first of three posts on the actual AIR ActionScript 3.0 Design Pattern catalog. Previously, <a href=http://www.as3dp.com/2009/07/07/deciding-on-a-design-pattern-a-graphic-and-text-catalog/>I had discussed the thinking that went into the design of the Catalog</a>, and here is the first actual AIR application with the Creational Patterns portion of the catalog all set up and ready to use.  Figure 1 shows what each page looks like: (By the way, the actual image in the catalog is almost twice the size as what you see in Figure 1.)</p>
<p><img src="http://www.as3dp.com/wp-content/uploads/2009/07/catalog1.png" alt="catalog1" title="catalog1" width="500" height="354" class="alignnone size-full wp-image-1152" /><br />
<em><strong>Figure 1: </strong>Design Pattern Catalog Page</em></p>
<p>Before going on, you can download all of the source code and the AIR application by clicking the Download button. Additionally, you may want to access the <a href="http://nemo.mwd.hartford.edu/~wsanders/dpcatalog/">Catalog Online</a>.<br />
<a href="http://nemo.mwd.hartford.edu/~wsanders/dpWork/Catalog1.zip"><br />
<img src="http://www.as3dp.com/wp-content/uploads/2009/07/download.png" alt="download" title="download" width="99" height="47" class="alignnone size-full wp-image-1153" /></a></p>
<p>I changed the color combinations. I concluded that Kuler’s  <em>1944mustang </em> color set was the best for this project because I needed a white background and I liked the orange for highlight. I used red for labeling on the diagrams, but it was used sparsely and provided a consistency.<br />
<span id="more-1151"></span><br />
After several false starts, I finally settled on the Factory Method, and by the time I was finished, I was glad I did. It’s an easy design pattern, keeps the classes loosely connected and is very flexible. In fact I used two Factory Method patterns—one was reused from an earlier application where the factory method was used to send DataProvider data to the Client. (See <a href=http://www.as3dp.com/2009/06/16/friends-with-benefits-refactoring-with-multiple-design-patterns—part-i/>Refactoring with Multiple Design Patterns</a>.)</p>
<p>The new Factory Method created instances of the pages assembled from several text fields and a graphic. Initially, I was going to have a single Product class and a different ConcreteProduct class for each pattern (23 in all), and that was exactly what I started doing. However, I soon discovered that the only thing that I needed to do was to pass a string parameter with  the data name for each pattern, and a single ConcreteProduct class could handle the whole thing. Each of the classes representing a ConcreteProduct class was no smaller than the single <em> general</em> ConcreteProduct; so it did not necessitate bloating a class to cut down on the number of classes.</p>
<p>Finally, all of the data for the page are stored in folders for each individual design pattern. Each folder has a single PNG file and 12 text files. All of the contents of the 23 patterns have identical names and the pattern name is keyed to the folder name. Figure 2 shows an overview of the classes, the data folders and the Client connections to the data.<br />
<img src="http://www.as3dp.com/wp-content/uploads/2009/07/layout.png" alt="layout" title="layout" width="459" height="424" class="alignnone size-full wp-image-1156" /></p>
<p><em><strong>Figure 2: </strong>Files and Data Folders</em><br />
As you can see in Figure 2, using multiple design patterns of the same type is no different than using single design patterns or different design patterns simultaneously. All you need is to have your Client hooked in where it needs to make the request.</p>
<p><strong>Files, Files, Everywhere!</strong></p>
<p>Figure 2 shows only five of the needed 23 folders have been completed. Fortunately, only five design patterns are part of the Creational category; so I get a break between stints of the mind-numbing chore of adding text to text files. Adding the remaining folders is a matter of copying and pasting the current ones and then changing most of the text content and replacing the PNG file with the class diagram. If you’re in a hurry for the rest of the patterns you can do it yourself—most of the summaries are direct quotes from The Gang of Four or paraphrased to save space. The same is true with the rest of the materials, but I added the kinds of things that are specific to ActionScript 3.0, and of course the code snippets are all ActionScript 3.0. Figure 3 shows the contents of each folder:</p>
<p><img src="http://www.as3dp.com/wp-content/uploads/2009/07/files.png" alt="files" title="files" width="512" height="350" class="alignnone size-full wp-image-1158" /><br />
<em><strong>Figure 3: </strong>Text and Graphic files</em></p>
<p>Because all of the headers are the same, none of them have to be changed, and some of the text files are simply single words such as the name of the design pattern or the type of pattern. Using the <em>WhatVaries</em> AIR app, it’s easy to get what varies in each pattern as well. However, getting all of the text for components (participants), code examples and uses can be tricky because there’s only limited space for each.</p>
<p>While it may be tedious to enter all of the data for each and every design pattern, you’ll learn a lot—especially if you are using the Gang of Four’s book or <em>ActionScript 3.0 Design Patterns</em>. Also, there’s a lot of information on this blog you can use to fill out the data.</p>
<p>To add further design patterns here’s all you have to do:</p>
<ul>
<li>Copy and paste one of the current design pattern folders and all of its contents and then rename it using lower case no-space name. For example, the Chain of Responsibility can be named <strong>cor</strong>  </li>
<li>Add the label name and the data name of the design pattern in the CatData class. Use the <em>same</em> lowercase name for the data name as you used to name the folder for the pattern. </li>
<li>Draw a class diagram with a width no greater than 500px and save it as a PNG file using the name, <em>diagram.png</em> in the folder where you have the other files for the pattern.  </li>
<li>Open the text files and change the content to reflect the characteristics of the design pattern. The files with “head” in the filename (e.g., codehead.txt) should be left unchanged but still have to be in the folder </li>
</ul>
<p>That’s it. It also reflects what I like about design patterns. Once you get the basic structure set up; changes and reuse are easy.</p>
<p><strong>The Page-Making Factory</strong></p>
<p>Since we’re reusing a design pattern, you can review it at <a href=http://www.as3dp.com/2009/06/16/friends-with-benefits-refactoring-with-multiple-design-patterns—part-i/>Refactoring with Multiple Design Patterns </a>. However, to understand how the new use of the Factory Method works, each of the classes are reviewed here.</p>
<p>First of all, the Client is remarkably clean, and all requests, other than the initial one to provide data for the List component, relies on user-input in the List menu. <em>Only a single conditional statement</em> is used anywhere in this application, and it can be found in the Client where checking content in the DisplayObject. So you’ll find a very simple Client making requests for data and to see the content of a design pattern.  The following listing shows what little code is required in the Client class:</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('p1151code6'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p11516"><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
48
49
50
</pre></td><td class="code" id="p1151code6"><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> fl.<span style="color: #006600;">controls</span>.<span style="color: #0066CC;">List</span>;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">DataProvider</span>;
	<span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">events</span>.<span style="color: #006600;">ListEvent</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">//Client Class</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> factory:Creator = <span style="color: #000000; font-weight: bold;">new</span> ConcreteCreator  ;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> catalog:DataProvider;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">list</span>:<span style="color: #0066CC;">List</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">List</span>  ;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> dp:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> dpDisplay:Sprite;
&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>
			setMenu<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> setMenu<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">//Re-use Factory that provides data for DataProvider</span>
			<span style="color: #000000; font-weight: bold;">var</span> create:DPCreator = <span style="color: #000000; font-weight: bold;">new</span> ConcreteDPCreator  ;
			<span style="color: #000000; font-weight: bold;">var</span> catalog:DataProvider = <span style="color: #000000; font-weight: bold;">new</span> DataProvider  ;
			catalog = create.<span style="color: #006600;">selectData</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #808080; font-style: italic;">//Set up the list</span>
			<span style="color: #0066CC;">list</span>.<span style="color: #006600;">setSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">126</span>,<span style="color: #cc66cc;">650</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">list</span>.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">0</span>,<span style="color: #0066CC;">list</span>.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">0</span>;
			<span style="color: #0066CC;">list</span>.<span style="color: #006600;">dataProvider</span> = catalog;
			addChild<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">list</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">list</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ListEvent.<span style="color: #006600;">ITEM_CLICK</span>,choosePattern<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> choosePattern<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:ListEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			dp = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">item</span>.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #808080; font-style: italic;">//Only conditional in the entire program</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>dpDisplay<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				removeChild<span style="color: #66cc66;">&#40;</span>dpDisplay<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			dpDisplay = factory.<span style="color: #006600;">makeDP</span><span style="color: #66cc66;">&#40;</span>dp<span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>dpDisplay<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>As you can see, once the List menu is set up, the choosePattern() method does all the work. Further it is accomplished using very little code.</p>
<p>The next class is the Creator. It supplies the interface for the factory. As an abstract class, it cannot be instantiated, but you can include implemented methods. In this case, one method is implemented and the other is abstract.</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('p1151code7'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p11517"><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
</pre></td><td class="code" id="p1151code7"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">//Asbstract class</span>
	<span style="color: #808080; font-style: italic;">//Creator</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;">errors</span>.<span style="color: #006600;">IllegalOperationError</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Creator
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> dpNow:Sprite;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> makeDP<span style="color: #66cc66;">&#40;</span>dp:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:Sprite
		<span style="color: #66cc66;">&#123;</span>
			dpNow = chooseDP<span style="color: #66cc66;">&#40;</span>dp<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> dpNow;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// ABSTRACT Method (must be overridden in a subclass)</span>
		protected <span style="color: #000000; font-weight: bold;">function</span> chooseDP<span style="color: #66cc66;">&#40;</span>dp:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:Sprite
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</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 factory itself is a subclass of the abstract Creator class. It must implement the abstract method, and really nothing else. Originally when I had planned on individual ConcreteProduct classes for each design pattern, I had a big <strong>switch</strong> statement with 23 cases. However, by adding a parameter to the Catalog constructor (the ConcreteProduct class), all that’s passed is a string based on the List selected item’s data value.</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('p1151code8'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p11518"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p1151code8"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">//Factory</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;">errors</span>.<span style="color: #006600;">IllegalOperationError</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ConcreteCreator <span style="color: #0066CC;">extends</span> Creator
	<span style="color: #66cc66;">&#123;</span>
		override protected <span style="color: #000000; font-weight: bold;">function</span> chooseDP<span style="color: #66cc66;">&#40;</span>dp:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:Sprite
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Catalog<span style="color: #66cc66;">&#40;</span>dp<span style="color: #66cc66;">&#41;</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><strong>The Product and Concrete Product Classes</strong></p>
<p>The <strong>big</strong> classes in this application are the two that handle the product elements. That should not come as a surprise because the product is pretty big—12 text fields with text and a graphic file. The abstract Product class has both abstract and implemented methods and lots of them.  With 284 lines of code (including spaces and comments), this was the biggest abstract class I’d ever created. Half the methods are abstract and the other half are implemented. Essentially, it works like a giant getter/setter—or loader/placer to be more precise. Once each load is complete, a mirror function (method) “catches” the loaded materials and places it where it belongs on the DisplayObject (<em>aka</em> stage).</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('p1151code9'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p11519"><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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
</pre></td><td class="code" id="p1151code9"><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;">errors</span>.<span style="color: #006600;">IllegalOperationError</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLLoader</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: #0066CC;">text</span>.<span style="color: #0066CC;">TextField</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #006600;">TextFieldType</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextFormat</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">//Abstract class</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Product <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> loadCheck:URLLoader;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> txtFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> typeFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> sumHeadFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> sumFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> varyHeadFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> varyFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> usesHeadFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> usesFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> codeHeadFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> codeFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> comHeadFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><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> comFld:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">textFormat</span>:<span style="color: #0066CC;">TextFormat</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">private</span> const <span style="color: #0066CC;">TEXTCOLOR</span>:uint = 0x263248;
		<span style="color: #0066CC;">private</span> const TYPECOLOR:uint = 0xFF9800;
		<span style="color: #0066CC;">private</span> const HEADCOLOR:uint = 0x263248;
		<span style="color: #0066CC;">private</span> const BODYCOLOR:uint = 0x000000;
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadInfo<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadType<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadSumHead<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadSum<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadVaryHead<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadVary<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadUsesHead<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadUses<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadCodeHead<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadCode<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadComHead<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> loadCom<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">//Already Loaded</span>
		protected <span style="color: #000000; font-weight: bold;">function</span> nowLoaded<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial Black&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">18</span>;
			txtFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			txtFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">300</span>;
			txtFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			txtFld.<span style="color: #0066CC;">textColor</span> = <span style="color: #0066CC;">TEXTCOLOR</span>;
			txtFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			txtFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>txtFld<span style="color: #66cc66;">&#41;</span>;
			txtFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">128</span>,txtFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">10</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowType<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial Black&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">14</span>;
			typeFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			typeFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">300</span>;
			typeFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			typeFld.<span style="color: #0066CC;">textColor</span> = TYPECOLOR;
			typeFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			typeFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>typeFld<span style="color: #66cc66;">&#41;</span>;
			typeFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">368</span>,typeFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">16</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowSumHead<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial Black&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">14</span>;
			sumHeadFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			sumHeadFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">175</span>;
			sumHeadFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			sumHeadFld.<span style="color: #0066CC;">textColor</span> = HEADCOLOR;
			sumHeadFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			sumHeadFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>sumHeadFld<span style="color: #66cc66;">&#41;</span>;
			sumHeadFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">148</span>,sumHeadFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">409</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowSum<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">12</span>;
			sumFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			sumFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">200</span>;
			sumFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			sumFld.<span style="color: #0066CC;">textColor</span> = BODYCOLOR;
			sumFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			sumFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>sumFld<span style="color: #66cc66;">&#41;</span>;
			sumFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">148</span>,sumFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">431</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowVaryHead<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial Black&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">14</span>;
			varyHeadFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			varyHeadFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">175</span>;
			varyHeadFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			varyHeadFld.<span style="color: #0066CC;">textColor</span> = HEADCOLOR;
			varyHeadFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			varyHeadFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>varyHeadFld<span style="color: #66cc66;">&#41;</span>;
			varyHeadFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">684</span>,varyHeadFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">409</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowVary<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">12</span>;
			varyFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			varyFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">175</span>;
			varyFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			varyFld.<span style="color: #0066CC;">textColor</span> = BODYCOLOR;
			varyFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			varyFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>varyFld<span style="color: #66cc66;">&#41;</span>;
			varyFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">684</span>,varyFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">431</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowUsesHead<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial Black&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">14</span>;
			usesHeadFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			usesHeadFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">175</span>;
			usesHeadFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			usesHeadFld.<span style="color: #0066CC;">textColor</span> = HEADCOLOR;
			usesHeadFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			usesHeadFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>usesHeadFld<span style="color: #66cc66;">&#41;</span>;
			usesHeadFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">148</span>,usesHeadFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">504</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowUses<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">12</span>;
			usesFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			usesFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">175</span>;
			usesFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			usesFld.<span style="color: #0066CC;">textColor</span> = BODYCOLOR;
			usesFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			usesFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>usesFld<span style="color: #66cc66;">&#41;</span>;
			usesFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">148</span>,usesFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">528</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowCodeHead<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial Black&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">14</span>;
			codeHeadFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			codeHeadFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">175</span>;
			codeHeadFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			codeHeadFld.<span style="color: #0066CC;">textColor</span> = HEADCOLOR;
			codeHeadFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			codeHeadFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>codeHeadFld<span style="color: #66cc66;">&#41;</span>;
			codeHeadFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">350</span>,codeHeadFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">409</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowCode<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Courier New&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">12</span>;
			codeFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			codeFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">323</span>;
			codeFld.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">215</span>;
			codeFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			codeFld.<span style="color: #0066CC;">textColor</span> = BODYCOLOR;
			codeFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			codeFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>codeFld<span style="color: #66cc66;">&#41;</span>;
			codeFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">350</span>,codeFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">430</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowComHead<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial Black&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">14</span>;
			comHeadFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			comHeadFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">175</span>;
			comHeadFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			comHeadFld.<span style="color: #0066CC;">textColor</span> = HEADCOLOR;
			comHeadFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			comHeadFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>comHeadFld<span style="color: #66cc66;">&#41;</span>;
			comHeadFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">684</span>,comHeadFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">458</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		protected <span style="color: #000000; font-weight: bold;">function</span> nowCom<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			loadCheck = URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">font</span> = <span style="color: #ff0000;">&quot;Arial&quot;</span>;
			<span style="color: #0066CC;">textFormat</span>.<span style="color: #0066CC;">size</span> = <span style="color: #cc66cc;">12</span>;
			comFld.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #0066CC;">DYNAMIC</span>;
			comFld.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">242</span>;
			comFld.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">164</span>;
			comFld.<span style="color: #0066CC;">wordWrap</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			comFld.<span style="color: #0066CC;">textColor</span> = BODYCOLOR;
			comFld.<span style="color: #006600;">defaultTextFormat</span> = <span style="color: #0066CC;">textFormat</span>;
			comFld.<span style="color: #0066CC;">text</span> = loadCheck.<span style="color: #0066CC;">data</span>;
			addChild<span style="color: #66cc66;">&#40;</span>comFld<span style="color: #66cc66;">&#41;</span>;
			comFld.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">684</span>,comFld.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">480</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #808080; font-style: italic;">//Load Image</span>
		protected <span style="color: #000000; font-weight: bold;">function</span> loadImg<span style="color: #66cc66;">&#40;</span>img:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> IllegalOperationError<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Abstract method: must be overridden in a subclass&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Each implemented method works the same. It gets the Event instance from the loading sequence (implemented in the Catalog class—a Concrete Product) and then puts it where it belongs and formats it.</p>
<p>Finally, the ConcreteProduct is the Catalog class. It loads all of the materials it needs and then uses the methods it inherited from the Product class to place the text and graphic.</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('p1151code10'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p115110"><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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
</pre></td><td class="code" id="p1151code10"><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;">net</span>.<span style="color: #006600;">URLRequest</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Loader</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;">net</span>.<span style="color: #006600;">URLLoader</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> Catalog <span style="color: #0066CC;">extends</span> Product
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> dp:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> nameText:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> typeText:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> sumHead:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> sumText:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> varyHead:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> varyText:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> usesHead:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> usesText:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> codeHead:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> codeText:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> comHead:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> comText:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> dpImage:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">url</span>:URLRequest;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> loader:Loader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> fileNow:URLRequest;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> txtLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> typeLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> sumHeadLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> sumLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> varyHeadLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> varyLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> usesHeadLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> usesLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> codeHeadLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> codeLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> comHeadLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> comLoader:URLLoader;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> loadCheck:URLLoader;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Catalog<span style="color: #66cc66;">&#40;</span>dp:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">dp</span>=dp;
			dp+=<span style="color: #ff0000;">&quot;/&quot;</span>;
			nameText = dp + <span style="color: #ff0000;">&quot;name.txt&quot;</span>;
			typeText = dp + <span style="color: #ff0000;">&quot;type.txt&quot;</span>;
			sumHead = dp + <span style="color: #ff0000;">&quot;sumhead.txt&quot;</span>;
			sumText = dp + <span style="color: #ff0000;">&quot;summary.txt&quot;</span>;
			varyHead = dp + <span style="color: #ff0000;">&quot;varyhead.txt&quot;</span>;
			varyText = dp + <span style="color: #ff0000;">&quot;vary.txt&quot;</span>;
			usesHead = dp + <span style="color: #ff0000;">&quot;useshead.txt&quot;</span>;
			usesText = dp + <span style="color: #ff0000;">&quot;uses.txt&quot;</span>;
			codeHead = dp + <span style="color: #ff0000;">&quot;codehead.txt&quot;</span>;
			codeText = dp + <span style="color: #ff0000;">&quot;code.txt&quot;</span>;
			comHead = dp + <span style="color: #ff0000;">&quot;comhead.txt&quot;</span>;
			comText = dp + <span style="color: #ff0000;">&quot;com.txt&quot;</span>;
			dpImage = dp + <span style="color: #ff0000;">&quot;diagram.png&quot;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">//All of these function are below</span>
			loadInfo<span style="color: #66cc66;">&#40;</span>nameText<span style="color: #66cc66;">&#41;</span>;
			loadType<span style="color: #66cc66;">&#40;</span>typeText<span style="color: #66cc66;">&#41;</span>;
			loadSumHead<span style="color: #66cc66;">&#40;</span>sumHead<span style="color: #66cc66;">&#41;</span>;
			loadSum<span style="color: #66cc66;">&#40;</span>sumText<span style="color: #66cc66;">&#41;</span>;
			loadVaryHead<span style="color: #66cc66;">&#40;</span>varyHead<span style="color: #66cc66;">&#41;</span>;
			loadVary<span style="color: #66cc66;">&#40;</span>varyText<span style="color: #66cc66;">&#41;</span>;
			loadUsesHead<span style="color: #66cc66;">&#40;</span>usesHead<span style="color: #66cc66;">&#41;</span>;
			loadUses<span style="color: #66cc66;">&#40;</span>usesText<span style="color: #66cc66;">&#41;</span>;
			loadCodeHead<span style="color: #66cc66;">&#40;</span>codeHead<span style="color: #66cc66;">&#41;</span>;
			loadCode<span style="color: #66cc66;">&#40;</span>codeText<span style="color: #66cc66;">&#41;</span>;
			loadComHead<span style="color: #66cc66;">&#40;</span>comHead<span style="color: #66cc66;">&#41;</span>;
			loadCom<span style="color: #66cc66;">&#40;</span>comText<span style="color: #66cc66;">&#41;</span>;
			loadImg<span style="color: #66cc66;">&#40;</span>dpImage<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadInfo<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			txtLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			txtLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowLoaded<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			txtLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadType<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			typeLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			typeLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowType<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			typeLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadSumHead<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			sumHeadLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			sumHeadLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowSumHead<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			sumHeadLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadSum<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			sumLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			sumLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowSum<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			sumLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadVaryHead<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			varyHeadLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			varyHeadLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowVaryHead<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			varyHeadLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadVary<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			varyLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			varyLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowVary<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			varyLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadUsesHead<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			usesHeadLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			usesHeadLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowUsesHead<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			usesHeadLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadUses<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			usesLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			usesLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowUses<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			usesLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadCodeHead<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			codeHeadLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			codeHeadLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowCodeHead<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			codeHeadLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadCode<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			codeLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			codeLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowCode<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			codeLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadComHead<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			comHeadLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			comHeadLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowComHead<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			comHeadLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadCom<span style="color: #66cc66;">&#40;</span>txtInfo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			comLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			comLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,nowCom<span style="color: #66cc66;">&#41;</span>;
			fileNow = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>txtInfo<span style="color: #66cc66;">&#41;</span>;
			comLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>fileNow<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">//Load image</span>
		override protected <span style="color: #000000; font-weight: bold;">function</span> loadImg<span style="color: #66cc66;">&#40;</span>dpImage:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">url</span> = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>dpImage<span style="color: #66cc66;">&#41;</span>;
			loader=<span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>loader<span style="color: #66cc66;">&#41;</span>;
			loader.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">128</span>,loader.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">34</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>That’s the whole enchilada, and it is a big one. Both of the product classes are much bigger than I like, but the nature of the application requires it. However, even with all of the methods and instances in two different Factory Method class sets, there’s only a single conditional statement, and it’s in the Client—where it doesn’t count as part of the design pattern. (I could even eliminate it if I put in a dummy display sprite—but why go fanatic?)</p>
<p><strong>Finishing Up</strong></p>
<p>All that’s left are 17 more design patterns and some kind of splash page. I think that the splash page should have the different elements of the UML class diagrams—what the different arrows and symbols mean.  If you can think of anything else, let us know. Also, play around with the AIR version and let me know if you have any additional features that you think would help. Also, if you want to pitch in and help fill in the different design patterns data, contact me and I’ll be glad to recruit you! (Is there such a thing as an online <strong>Hero Medal</strong>?)</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%2F07%2Factionscript-30-design-pattern-catalog-creational-patterns%2F&amp;title=ActionScript%203.0%20Design%20Pattern%20Catalog%3A%20Creational%20Patterns" 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/2009/07/actionscript-30-design-pattern-catalog-creational-patterns/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Developing an AIR ActionScript 3.0 Design Pattern Catalog and the AIR Magic Table</title>
		<link>http://www.as3dp.com/2009/06/the-developing-an-air-actionscript-30-design-pattern-catalog-and-the-air-magic-table/</link>
		<comments>http://www.as3dp.com/2009/06/the-developing-an-air-actionscript-30-design-pattern-catalog-and-the-air-magic-table/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 13:49:05 +0000</pubDate>
		<dc:creator>William B. Sanders</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Catalog]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Design Patterns at Work]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.as3dp.com/?p=1070</guid>
		<description><![CDATA[Gentle Reader, this post includes one completed application and one in the works. The AIR ActionScript 3.0 Design Pattern Catalog is meant to be a developer’s aid, and so your ideas of what to include in the catalog is important. We would really appreciate your comments on what you think would be useful in developing [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.as3dp.com/wp-content/uploads/2009/06/magicapp.png" alt="magicapp" title="magicapp" width="111" height="65" class="alignleft size-full wp-image-1071" /><br />
<em><strong>Gentle Reader,</strong> this post includes one completed application and one in the works. The AIR ActionScript 3.0 Design Pattern Catalog is meant to be a developer’s aid, and so your ideas of what to include in the catalog is important. We would really appreciate your comments on what you think would be useful in developing an information template to be used for all of the design patterns.</em></p>
<p>I recently returned from a trip to Prague in the Czech Republic, and I went to work creating a video player for my HD videos I made using a Flip Mino HD camcorder (http://www.sandlight.net/prague). Rather than pulling out and reusing my trusty State Design Pattern player (see Chapter 10), I decided to start from scratch and create a player not using a design pattern. Then I would take the completed video player and use it as an example to show how to refactor a program to a design pattern. (<em>This will be in an upcoming post.</em>) Since I’ve never had to refactor the original program (tweak, maybe but not refactor), and I hadn’t worked with a State pattern lately, I found myself digging up all of the materials on the State Design Pattern. What I wished I had was a handy desktop app that I could click that would show me the essentials of the different design patterns. It would be an <strong>abbreviated design pattern catalog</strong> that could be used like the little <a href="http://www.as3dp.com/2009/02/26/oop-designs-pattern-principles-ready-for-work/">Design Pattern Principles and Lunch Bucket Rules</a> AIR app. Then when I need a quick reference I could use the desktop app to look up the essentials of the pattern.<br />
<span id="more-1070"></span><br />
<strong>What Does a Design Pattern Catalog Need?</strong></p>
<p>Right off the top of my head I came up with the following elements for a quick look-up:</p>
<ul>
<li>Class diagram</li>
<li>Description of what elements vary</li>
<li>Component roles</li>
<li>Common usage </li>
<li>Chapter/Blog reference</li>
<li>Key Code examples</li>
</ul>
<p>The catalog is meant to be a quick reference for someone who has some idea design patterns and wants to check out some elements of different patterns to see if it&#8217;s appropriate for a project. It is not meant to be a complete reference and certainly not a tutorial. Like the little AIR application that brings up the principles in abbreviated format, this application is meant to be a simple guide that will save time over pouring through Web searches or books and articles for basic design pattern information. Figure 1 shows an idea of what each page of the application would look like (given the above criteria). We’d like your comments on further ideas both in content and design. <em>I’m not a designer</em>.<br />
<img src="http://www.as3dp.com/wp-content/uploads/2009/06/catalog.png" alt="catalog" title="catalog" width="500" height="500" class="alignnone size-full wp-image-1072" /></p>
<p><em><strong>Figure 1:</strong> Proposed Template for ActionScript 3.0 Design Pattern Catalog</em></p>
<p>Take a look at Figure 1 and see if you have any suggestions as to how we could make it more useful without going into a detailed explanation of the pattern. Would it be handy? Should anything be added or deleted? Is there a better design? Send in your comments.</p>
<p><strong>The Magic Table in AIR</strong></p>
<p>A while back we had a post on this blog that included what I called <a href="http://www.as3dp.com/2009/03/10/variation-table/"> The Magic Table</a>.  It is a reference to the Gang of Four’s table where they list all of the design patterns and what can vary for the pattern. Anyway, I’ve always found that table useful, and so I created one using a simple DataGrid component. You can <a href="http://www.sandlight.com/magic/">download it here</a>. You can put the AIR app on your desktop and quickly find what can vary with each design pattern. Figure 2 shows what you’ll see.<br />
<!--more--><br />
<img src="http://www.as3dp.com/wp-content/uploads/2009/06/vary.png" alt="vary" title="vary" width="630" height="522" class="alignnone size-full wp-image-1073" /></p>
<p><em><strong>Figure 2:</strong> Encapsulate what varies—Design Pattern Variation Table in AIR</em></p>
<p>If you can make something with better aesthesis, please do so, and we’ll be glad to make it available to our blog readers if it is sent in an AIR file.  In the meantime, we’d like to get your comments on the utility of such tools and ideas to improve them.</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%2F06%2Fthe-developing-an-air-actionscript-30-design-pattern-catalog-and-the-air-magic-table%2F&amp;title=The%20Developing%20an%20AIR%20ActionScript%203.0%20Design%20Pattern%20Catalog%20and%20the%20AIR%20Magic%20Table" 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/2009/06/the-developing-an-air-actionscript-30-design-pattern-catalog-and-the-air-magic-table/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

