<?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>ria-coder.com &#187; Flex</title>
	<atom:link href="http://ria-coder.com/blog/tag/flex/feed" rel="self" type="application/rss+xml" />
	<link>http://ria-coder.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 21 Apr 2010 19:35:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Truly Cached Flex Modules</title>
		<link>http://ria-coder.com/blog/truly-cached-flex-modules</link>
		<comments>http://ria-coder.com/blog/truly-cached-flex-modules#comments</comments>
		<pubDate>Sun, 31 Jan 2010 19:56:14 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[modules]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=532</guid>
		<description><![CDATA[I was working on a project recently and I discovered (or possibly misunderstood - see disclaimer) that Flex does not cache modules correctly, or - at the very least - it does not do it effectively according to my tests.]]></description>
			<content:encoded><![CDATA[<p>I was working on a project recently and I discovered (or possibly misunderstood &#8211; see disclaimer) that Flex does <strong>not</strong> cache modules correctly, or &#8211; at the very least &#8211; it does not do it effectively according to my tests.</p>
<p><em>My test was conducted using Flex SDK <strong>3.4.0.9271, </strong>Firefox <strong>3.5.7 </strong>and <strong>Flex Builder Professional 3.0.214193</strong></em></p>
<p>According to <a title="Adobe LiveDocs" href="http://livedocs.adobe.com/flex/3/html/help.html?content=modular_5.html" target="_blank">this</a> page (under the <strong>Preloading modules</strong> heading), Adobe asserts the following:</p>
<blockquote><p>When a module is loaded by the Flex application for the first time, the module&#8217;s SWF file is transferred across the network and stored in the browser&#8217;s cache. If the Flex application unloads that module, but then later reloads it, there should be less wait time because Flash Player loads the module from the cache rather than across the network.</p>
<p>Module SWF files, like all SWF files, reside in the browser&#8217;s cache unless and until a user clears them. As a result, modules can be loaded by the main application across several sessions, reducing load time; but this depends on how frequently the browser&#8217;s cache is flushed.</p></blockquote>
<p>I found the above claims to be demonstrably false, or at least just plain inefficient&#8230;</p>
<p>Let me qualify this:<br />
According to my tests (conducted with my Firefox browser cache turned both on and off), i found that the application&#8217;s memory usage keeps growing exponentially when switching between two loaded modules. There was a variance (as you&#8217;d imagine) when the browser cache was left on but nonetheless, the memory usage keeps growing steadily.</p>
<p>In the code sample below, I have extended the functionality of the <strong>mx.modules.ModuleLoader</strong> class, and added a Dictionary (with a little logic) to manage the (ostensibly) effective caching of previously loaded modules. I have not tested this class extensively, but all the tests that I conducted seemed to produce a significant memory and speed improvement.</p>

<div class="wp_syntax"><table><tr><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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">DisplayObject</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">DisplayObjectContainer</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">Dictionary</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> mx.events.FlexEvent;
	<span style="color: #0033ff; font-weight: bold;">import</span> mx.events.ModuleEvent;
	<span style="color: #0033ff; font-weight: bold;">import</span> mx.modules.IModuleInfo;
	<span style="color: #0033ff; font-weight: bold;">import</span> mx.modules.ModuleLoader;
	<span style="color: #0033ff; font-weight: bold;">import</span> mx.modules.ModuleManager;
&nbsp;
	<span style="color: #3f5fbf;">/**
	 * This class manages the loading, unloading and caching of Flex Modules
	 * This is a modified version of the mx.modules.ModuleLoader class
	 *
	 * @author Danny Kopping - danny@ria-coder.com
	 */</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> CachedModuleLoader extends ModuleLoader
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">map</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Dictionary</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Dictionary</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _url<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #0033ff; font-weight: bold;">null</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> module<span style="color: #000000; font-weight: bold;">:</span>IModuleInfo;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> loadRequested<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> CachedModuleLoader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> <span style="color: #004993;">url</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span> == _url<span style="color: #000000;">&#41;</span>
				<span style="color: #0033ff; font-weight: bold;">return</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>module<span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				module.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.<span style="color: #004993;">PROGRESS</span>, moduleProgressHandler<span style="color: #000000;">&#41;</span>;
				module.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.SETUP, moduleSetupHandler<span style="color: #000000;">&#41;</span>;
				module.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.READY, moduleReadyHandler<span style="color: #000000;">&#41;</span>;
				module.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.<span style="color: #004993;">ERROR</span>, moduleErrorHandler<span style="color: #000000;">&#41;</span>;
				module.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.<span style="color: #004993;">UNLOAD</span>, moduleUnloadHandler<span style="color: #000000;">&#41;</span>;
&nbsp;
				<span style="color: #009900;">//module.release();</span>
				module = <span style="color: #0033ff; font-weight: bold;">null</span>;
&nbsp;
				<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">child</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">child</span><span style="color: #000000;">&#41;</span>;
					<span style="color: #009900;">//child = null;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
			_url = <span style="color: #004993;">value</span>;
&nbsp;
			<span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlexEvent<span style="color: #000000;">&#40;</span>FlexEvent.URL_CHANGED<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			removeAllChildren<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_url <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> loadRequested<span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span><span style="color: #004993;">map</span><span style="color: #000000;">&#91;</span>_url<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>
					loadModule<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #0033ff; font-weight: bold;">else</span>
				<span style="color: #000000;">&#123;</span>
&nbsp;
					<span style="color: #004993;">child</span> = <span style="color: #004993;">map</span><span style="color: #000000;">&#91;</span>_url<span style="color: #000000;">&#93;</span>;
					<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">child</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> <span style="color: #004993;">url</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> _url;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> createComponentsFromDescriptors<span style="color: #000000;">&#40;</span>recurse<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span>.createComponentsFromDescriptors<span style="color: #000000;">&#40;</span>recurse<span style="color: #000000;">&#41;</span>;
&nbsp;
			loadRequested = <span style="color: #0033ff; font-weight: bold;">true</span>;
			loadModule<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> loadModule<span style="color: #000000;">&#40;</span><span style="color: #004993;">url</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #0033ff; font-weight: bold;">null</span>, bytes<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
				_url = <span style="color: #004993;">url</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_url == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">//trace(&quot;loadModule() - null url&quot;);</span>
				<span style="color: #0033ff; font-weight: bold;">return</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">map</span><span style="color: #000000;">&#91;</span>_url<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">//trace(&quot;loadModule() - already created the child&quot;);</span>
				<span style="color: #0033ff; font-weight: bold;">return</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>module<span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #009900;">//trace(&quot;loadModule() - load already initiated&quot;);</span>
				<span style="color: #0033ff; font-weight: bold;">return</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlexEvent<span style="color: #000000;">&#40;</span>FlexEvent.LOADING<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			module = ModuleManager.getModule<span style="color: #000000;">&#40;</span>_url<span style="color: #000000;">&#41;</span>;
&nbsp;
			module.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.<span style="color: #004993;">PROGRESS</span>, moduleProgressHandler<span style="color: #000000;">&#41;</span>;
			module.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.SETUP, moduleSetupHandler<span style="color: #000000;">&#41;</span>;
			module.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.READY, moduleReadyHandler<span style="color: #000000;">&#41;</span>;
			module.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.<span style="color: #004993;">ERROR</span>, moduleErrorHandler<span style="color: #000000;">&#41;</span>;
			module.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.<span style="color: #004993;">UNLOAD</span>, moduleUnloadHandler<span style="color: #000000;">&#41;</span>;
&nbsp;
			module.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">applicationDomain</span>, <span style="color: #0033ff; font-weight: bold;">null</span>, bytes<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> unloadModule<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">child</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">contains</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">child</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">child</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #004993;">child</span> = <span style="color: #0033ff; font-weight: bold;">null</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>module<span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				module.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.<span style="color: #004993;">PROGRESS</span>, moduleProgressHandler<span style="color: #000000;">&#41;</span>;
				module.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.SETUP, moduleSetupHandler<span style="color: #000000;">&#41;</span>;
				module.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.READY, moduleReadyHandler<span style="color: #000000;">&#41;</span>;
				module.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.<span style="color: #004993;">ERROR</span>, moduleErrorHandler<span style="color: #000000;">&#41;</span>;
&nbsp;
				module.<span style="color: #004993;">unload</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				module.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>ModuleEvent.<span style="color: #004993;">UNLOAD</span>, moduleUnloadHandler<span style="color: #000000;">&#41;</span>;
				module = <span style="color: #0033ff; font-weight: bold;">null</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">map</span><span style="color: #000000;">&#91;</span>_url<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">delete</span> <span style="color: #004993;">map</span><span style="color: #000000;">&#91;</span>_url<span style="color: #000000;">&#93;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> moduleProgressHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>ModuleEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> moduleSetupHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>ModuleEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">// Not ready for creation yet, but can call factory.info().</span>
&nbsp;
			<span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> moduleReadyHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>ModuleEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">child</span> = module.factory.create<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">DisplayObject</span>;
			<span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">child</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> p<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">DisplayObjectContainer</span> = <span style="color: #004993;">parent</span>;
				<span style="color: #009900;">// p.removeChild(this);</span>
				<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">child</span><span style="color: #000000;">&#41;</span>;
&nbsp;
				<span style="color: #004993;">map</span><span style="color: #000000;">&#91;</span><span style="color: #004993;">url</span><span style="color: #000000;">&#93;</span> = <span style="color: #004993;">child</span>;<span style="color: #009900;">//ModuleManager.getModule(_url);</span>
				<span style="color: #009900;">//trace(map + &quot;:&quot; + url + &quot;:&quot; + map[url]);</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> moduleErrorHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>ModuleEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			unloadModule<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> moduleUnloadHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span>ModuleEvent<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>The usage of this class is exactly the same as the regular <strong>mx.modules.ModuleLoader</strong> class. I hope this helps!</p>
<p><strong>Download this file:</strong> <a href="http://ria-coder.com/blog/wp-content/uploads/2010/01/CachedModuleLoader.as">Download</a></p>
<p><strong>**DISCLAIMER**<br />
<span style="font-weight: normal; ">I know a bit about Flex modules from hours of obsessing over them, but i <span style="text-decoration: underline;">do not know everything</span>. From my tests of the efficacy of the above code &amp; explanation, i found that it reduces memory usage and increases the general usability of my Flex project; i could be very wrong on this topic, and if i am &#8211; please tell me. Maybe i&#8217;m just an idiot, but it seems to work&#8230;</span></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/truly-cached-flex-modules/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using a Custom Cursor in Flex with CSS</title>
		<link>http://ria-coder.com/blog/using-a-custom-cursor-in-flex-with-css</link>
		<comments>http://ria-coder.com/blog/using-a-custom-cursor-in-flex-with-css#comments</comments>
		<pubDate>Wed, 16 Dec 2009 21:54:22 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[cursor]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[stylesheet]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=511</guid>
		<description><![CDATA[Learn how to define a custom Flex busy cursor in pure CSS]]></description>
			<content:encoded><![CDATA[<p>If you want to use a custom <em>busyCursor</em> animation in your Flex applications, you don&#8217;t need to do anything fancy&#8230; All you have to do is define one, solitary property in your CSS file:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">CursorManager
<span style="color: #00AA00;">&#123;</span>
	<span style="color: #808080; font-style: italic;">/* You can use PNGs, SWFs or JPEGs */</span>
	busyCursor<span style="color: #00AA00;">:</span> Embed<span style="color: #00AA00;">&#40;</span>source<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;path/to/your/resource&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>
To invoke the busy cursor, use the following line:<br />
</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">CursorManager.<span style="color: #006600;">setBusyCursor</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>&#8230;or you could set the <em>showBusyCursor</em> to <strong>true</strong> in your HTTPService or RemoteObject instances.</p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/using-a-custom-cursor-in-flex-with-css/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QuickTip: asSQL Connection Problem with non-localhost hostname</title>
		<link>http://ria-coder.com/blog/assql-connection-problem-with-non-localhost-hostname</link>
		<comments>http://ria-coder.com/blog/assql-connection-problem-with-non-localhost-hostname#comments</comments>
		<pubDate>Sat, 12 Dec 2009 22:58:26 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[assql]]></category>
		<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=488</guid>
		<description><![CDATA[Read this post to fix that annoying error with asSQL when trying to connect to remote MySQL installations]]></description>
			<content:encoded><![CDATA[<p><a title="asSQL" href="http://code.google.com/p/assql/">asSQL</a> is just great. It&#8217;s an ActionScript 3.0 library  for connecting AIR applications to MySQL databases and it works brilliantly &#8211; when it works! Recently i gave it a shot again after an utter failure the last time i tried it&#8230; The library seems to be a port of the Java implementation of connecting to MySQL (<em>Connections, Statements, Fields, etc</em>). It takes a little getting used to but it&#8217;s an excellent library and i highly recommend it.<br />
<br />
<h2>Background</h2>
<p>My development environment is Windows-based (against my wishes&#8230; not enough loot or motivation for a Mac, lack of Adobe software on Linux) but i make up for this by running a virtual Linux installation in my Windows environment and networking the two together. It actually works really well, and the process for setting this up can be found <a title="Ubuntu + Windows" href="http://www.simonholywell.com/computing/internet/a-good-windows-development-environment-and-ubuntu-virtualbox.html">here</a>. To cut a very long and boring story short, essentially i cannot use <em>localhost</em> as your server when using this architecture since i have my LAMPP stack running on my Linux environment, so my &#8220;local server&#8221; can only be accessed using the IP address of the virtual system.</p>
<p>This complicates things a bit when trying to use asSQL to connect to my MySQL installation, because MySQL gets all paranoid and won&#8217;t accept connections from a foreign IP address (the IP of my Windows machine on which my AIR app is running)&#8230; To get around this, all you have to do is create a new user in MySQL (i used <a title="phpMyAdmin" href="http://phpmyadmin.net">phpMyAdmin</a>), set the user&#8217;s hostname to the IP address of your remote system (i&#8217;ve explained how to do this below) and you&#8217;re ready to rock and roll!<br />
<br />
<h2>Solution</h2>
<p>The first thing you need to do is get the IP address of the remote system&#8230;</p>
<p><strong>Windows: </strong>Open the command line, type <em>ipconfig<br />
<strong><span style="font-style: normal;">Linux</span><span style="font-weight: normal;"> </span><span style="font-style: normal;">&amp; Mac: <span style="font-weight: normal;">Open the terminal, type <em>ifconfig</em></span></span></strong></em></p>
<p><strong><span style="font-weight: normal;">In this example, my IP address is </span>192.168.56.1</strong></p>
<p>I&#8217;ll be using phpMyAdmin to fix the problem.</p>
<ol>
<li>Open phpMyAdmin and click on the <strong>Privileges</strong> tab.</li>
<li>Click <strong>Add a new User</strong></li>
<li>Enter any username you like, paste the IP address obtained in the <strong>Host</strong> field and put in a password</li>
<li>Under the <em>Database for user</em> panel, leave it at <strong>None</strong></li>
<li>Under the <em>Global privileges</em>, you can <strong>Check All</strong></li>
</ol>
<p>That should sort it out&#8230; Remember, this is <strong>HIGHLY</strong> insecure and should <strong>only be used on development environments and <span style="text-decoration: underline;">NOT</span> production environments.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/assql-connection-problem-with-non-localhost-hostname/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing that annoying feature of List controls</title>
		<link>http://ria-coder.com/blog/fixing-that-annoying-feature-of-list-controls</link>
		<comments>http://ria-coder.com/blog/fixing-that-annoying-feature-of-list-controls#comments</comments>
		<pubDate>Sun, 15 Nov 2009 21:57:07 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[creationPolicy]]></category>
		<category><![CDATA[offscreen]]></category>
		<category><![CDATA[tilelist]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=469</guid>
		<description><![CDATA[Learn how to fix that ever-painful "optimization" feature of Flex's list components]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t you just hate it&#8230; Doesn&#8217;t it just piss you off when you want to display a gallery of images in Flex and Flex decides that it&#8217;s actually going to set it so that when you scroll, it&#8217;ll <em>only</em> <em>then</em> load the images displayed offscreen? I find this particularly &#8220;ball-ache-ish&#8221; with the TileList component.</p>
<p>I was browsing through the documentation like i had many times before, but this time i noticed the <strong>offscreenExtraRowsOrColumns</strong> property. At first you think &#8220;wtf&#8221; but then i got curious&#8230;</p>
<p>Say you have 25 images in a grid that displays one row of 5 images at a time:</p>
<table border="0" width="200">
<tbody>
<tr style="background-color:#C7E811">
<td height="10px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr style="background-color:#DDDDDD">
<td height="10px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr style="background-color:#DDDDDD">
<td height="10px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr style="background-color:#DDDDDD">
<td height="10px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr style="background-color:#DDDDDD">
<td height="10px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>The row in green will be the only row visible at this point in time. When you scroll, Flex will chuck out the first row and create the second row:</p>
<table border="0" width="200">
<tbody>
<tr style="background-color:#DDDDDD">
<td height="10px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr style="background-color:#C7E811">
<td height="10px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr style="background-color:#DDDDDD">
<td height="10px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr style="background-color:#DDDDDD">
<td height="10px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr style="background-color:#DDDDDD">
<td height="10px"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>&#8230;and so on. Isn&#8217;t that just damn irritating? (If you&#8217;re thinking &#8220;nah, what&#8217;s the big deal?&#8221; then you obviously haven&#8217;t tried this before).</p>
<p>Anyway, the way to fix it is to tell Flex how many rows there are offscreen so that it can create them in the interim. This seems like a bit of a weird method because in the navigator classes (ViewStack, et al) there is a <strong>creationPolicy</strong> property which &#8211; when set to &#8220;all&#8221; &#8211; will create all the non-visible components before they&#8217;re navigated to, thus slowing down the processing a bit (depending on your app) but also speeding up the switch between views. Alas, no such property to be found in the TileList component. Can anybody tell me why? I think i should code a modified version of the TileList component to accept this property&#8230; <em>+1 to TODO list&#8230; *sigh*</em></p>
<p>Hopefully this will help those of you experiencing the ball-ache that i did.</p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/fixing-that-annoying-feature-of-list-controls/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Whirlwind that is Adobe in 2009</title>
		<link>http://ria-coder.com/blog/the-whirlwind-that-is-adobe-in-2009</link>
		<comments>http://ria-coder.com/blog/the-whirlwind-that-is-adobe-in-2009#comments</comments>
		<pubDate>Fri, 09 Oct 2009 09:40:34 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[catalyst]]></category>
		<category><![CDATA[flash builder]]></category>
		<category><![CDATA[max]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=447</guid>
		<description><![CDATA[It's been quite a fascinating year thus far; Adobe has really started getting serious about Flash, Flex and the developers involved]]></description>
			<content:encoded><![CDATA[<p>Wow.</p>
<p>It&#8217;s been quite a fascinating year thus far; Adobe has really started getting serious about Flash, Flex and the developers involved. This year, we have seen two amazing additions to Adobe&#8217;s web-dominating arsenal &#8211; <strong><a title="Flash Catalyst" href="http://labs.adobe.com/technologies/flashcatalyst/" target="_blank">Adobe Flash Catalyst</a> </strong>(now in beta 2)<strong> </strong>and <strong><a title="Flash Builder" href="http://labs.adobe.com/technologies/flashbuilder4/" target="_blank">Adobe Flash Builder 4</a></strong> (now in beta 2).<strong> </strong>After some preliminary buggering around in both of these, I came to the conclusion that working with a <em>beta</em> version of any software to create enterprise applications is putting yourself on the edge of the cliff, and working on a <em>version 1.0 beta</em> is hiring somebody to push you over the edge.</p>
<p>This raises an interesting catch-22:<br />
When a massive piece of software is released, the community has the onus to test it and give feedback on any bugs, requested features and expedience tips &#8211; however, if your beta software tends to be very buggy (and how could it not be? The SDK is <strong>huge</strong>) then how are you going to get<em> </em>developers to test your software on <em>real, enterprise</em> projects?</p>
<p>In any case, Adobe has really been playing the part this year. This year we have seen the release of the <a title="Flex 4 SDK" href="http://labs.adobe.com/technologies/flex4sdk/" target="_blank">Flex 4 SDK</a>, major advancements in the <a title="Open Screen Project" href="http://www.openscreenproject.org/" target="_blank">Open Screen Project</a>, Flash Player 10&#8242;s <a title="Some serious penetration" href="http://www.adobe.com/products/player_census/flashplayer/version_penetration.html" target="_blank">penetration rate to 93.5%</a>, AIR <a title="Some serious installation" href="http://blogs.adobe.com/air/2009/01/air_passes_100_million_install.html" target="_blank">surpassing 100 million</a> installations and the introduction of <a title="Flash Player 10.1" href="http://labs.adobe.com/technologies/flashplayer10/" target="_blank">Flash Player 10.1</a> most recently. Other great things i&#8217;ve seen are <a title="WorkflowLab" href="http://labs.adobe.com/technologies/workflowlab/" target="_blank">WorkflowLab</a>, <a title="BrowserLab" href="http://labs.adobe.com/technologies/browserlab/" target="_self">BrowserLab</a>, <a title="Squiggly" href="http://labs.adobe.com/technologies/squiggly/" target="_self">Project Squiggl</a>y, <a title="Slider" href="http://labs.adobe.com/technologies/flex/mobile/" target="_self">Slider</a> previews, <a title="Flash CS5" href="http://labs.adobe.com/technologies/flashcs5/" target="_blank">Flash CS</a>5 sneak previews and <a title="CommunityHelp" href="http://labs.adobe.com/technologies/communityhelp/" target="_blank">Community Help</a>.</p>
<p>For all of those unlucky and miserable enough to miss Adobe Max this year (myself included), there&#8217;s <a title="Max Videos" href="http://tv.adobe.com/show/max-2009-develop/" target="_blank">an entire channel</a> dedicated to Max 2009 Developer talks&#8230; Go check them out!</p>
<p>Oh, and if you have any luck getting these videos to play in <strong><a title="Adobe Media Player" href="http://labs.adobe.com/technologies/communityhelp/" target="_blank">Adobe Media Player</a></strong>, let me know. That app is more full of bugs than a salad in Nigeria.</p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/the-whirlwind-that-is-adobe-in-2009/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Belated Announcement</title>
		<link>http://ria-coder.com/blog/a-belated-announcement</link>
		<comments>http://ria-coder.com/blog/a-belated-announcement#comments</comments>
		<pubDate>Wed, 09 Sep 2009 12:01:26 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[danny kopping consulting]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=403</guid>
		<description><![CDATA[Danny Kopping Consulting opens up shop!]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-409" style="margin-right: 10px; margin-bottom: 2px;" title="Danny Kopping Consulting" src="http://ria-coder.com/temp/wp-content/uploads/2009/09/logo-smaller.jpg" alt="Danny Kopping Consulting" width="223" height="210" />Well, it&#8217;s been a week now since i officially left my old employer &#8211; IceBlue InfoTech (which has now been acquired by <a href="http://www.virtuosa.co.za">Virtuosa</a>)&#8230; I decided to start my own freelance consulting, development &amp; training firm, creatively named <strong><a href="http://www.dannykopping.co.za">Danny Kopping Consulting</a>. <span style="font-weight: normal;">Unfortunately, all the cool names were taken, so i went for the one that i knew wouldn&#8217;t be taken <img src='http://ria-coder.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</span></strong></p>
<p><span style="font-weight: normal;">I&#8217;ll be focusing primarily on building advanced, highly customized Flex-based systems and websites, using PHP, MySQL &amp; Apache on the back-end. I&#8217;ll also be doing some training on the side for Flash &amp; Flex (with a little PHP). Hopefully this freelance venture will pan out well and i&#8217;ll have even less time to muck about than i did before <img src='http://ria-coder.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </span></p>
<p><span style="font-weight: normal;"><br />
</span></p>
<p>A special thanks goes out to my best mate <a href="http://www.ndlh.co.za">Neil de la Harpe</a> for doing all my corporate branding!</p>
<p>I&#8217;ve set up a temporary site over at <a title="Danny Kopping Consulting Website" href="http://www.dannykopping.co.za/" target="_blank">http://www.dannykopping.co.za/</a>. Check it out&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/a-belated-announcement/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex font embedding nightmare</title>
		<link>http://ria-coder.com/blog/flex-font-embedding-nightmare</link>
		<comments>http://ria-coder.com/blog/flex-font-embedding-nightmare#comments</comments>
		<pubDate>Tue, 08 Sep 2009 19:35:55 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[embedding]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[preloader]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=401</guid>
		<description><![CDATA[There are many things that really irritate me - pretence, dishonesty, blind faith and Flex font embedding! Sometimes it makes me wonder whether i really exist... Ok, that's taking it a bit far, but it really grates my nuts sometimes]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="margin-left: 5px; margin-right: 5px;" title="Doh!" src="http://www.newyorkpersonalinjuryattorneyblog.com/uploaded_images/Doh-712993.jpg" alt="" width="157" height="264" />There are many things that really irritate me &#8211; pretence, dishonesty, blind faith and <strong>Flex font embedding</strong><strong>!</strong> Sometimes it makes me wonder whether i really exist&#8230; Ok, that&#8217;s taking it a bit far, but it really grates my nuts sometimes. I was recently (this evening) working on a website for a production company and i added a custom preloader from Flash (thank you <a title="Custom Preloaders in Flex" href="http://gotoandlearn.com/play?id=108" target="_blank">Mr Brimelow</a>!) to my Flex application. I&#8217;d embedded a font to use for the content in my site and i&#8217;d used the same font for the <em>percentage loaded</em> textfield in the preloader.</p>
<p>So i carried on happily putting the finishing touches on the site when disaster struck! The embedded fonts no longer showed up! I was perplexed&#8230; After about an hour of trying ever single bloody trick in the book and vociferous googling, i found&#8230; <strong>nothing</strong>. The worst part was that <span style="text-decoration: underline;">any other font</span> worked, except the one that i was using for the site, and the client needed that specific font &#8211; no compromise.</p>
<p>As luck would have it, i had a chance brainfart and decided to check my font embedding settings in my Flash preloader. Wouldn&#8217;t you know it&#8230; <strong>Flash was screwing up my fonts! </strong>It&#8217;s no fault of Flash&#8217;s though&#8230; It was embedding the fonts before Flex could, and it was embedding only a handful of glyphs.</p>
<p>So&#8230; Next time your fonts spontaneously stop working in Flex, check out any Flash resources you&#8217;re including in the site to make sure that the font embedding isn&#8217;t pernicious.</p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/flex-font-embedding-nightmare/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash &amp; Flex Developer&#039;s Magazine</title>
		<link>http://ria-coder.com/blog/flash-flex-developers-magazine</link>
		<comments>http://ria-coder.com/blog/flash-flex-developers-magazine#comments</comments>
		<pubDate>Wed, 02 Sep 2009 19:49:25 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[amfphp]]></category>
		<category><![CDATA[ffdmag]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=386</guid>
		<description><![CDATA[The new version of FFDMag is officially out! The publication is now an online-based magazine, available free of charge to all that want to check it out. Check out my article about Flex &#038; AMFPHP integration on Page 54.]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">The new version of FFDMag is officially out! The publication is now an online-based magazine, available free of charge to all that want to check it out.</p>
<p>Check out my article about Flex &amp; AMFPHP integration on Page 54&#8230;</p>
<p style="text-align: center;"><a href="http://www.ffdmag.com"><img class="aligncenter" style="margin-top: 5px; margin-bottom: 5px;" title="FFDMag 5" src="http://ffdmag.com//files/ffdmag/Cover/f&amp;f_magazine_05_2009.jpg" alt="" width="400" height="578" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/flash-flex-developers-magazine/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Runtime Shared Libraries &#8211; indispensable and infuriating!</title>
		<link>http://ria-coder.com/blog/runtime-shared-libraries-indispensable-and-infuriating</link>
		<comments>http://ria-coder.com/blog/runtime-shared-libraries-indispensable-and-infuriating#comments</comments>
		<pubDate>Wed, 22 Jul 2009 18:51:55 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[flex builder]]></category>
		<category><![CDATA[flex sdk]]></category>
		<category><![CDATA[rsl]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=354</guid>
		<description><![CDATA[Utilizing the RSL (Runtime Shared Library) mechanism in Flex is arguably one of the quickest and easiest ways to drastically shrink your Flex application&#8217;s file size. The RSL mechanism essentially allows you to compile your Flex application without embedding the Flex framework into the code. So, if the Flex framework isn&#8217;t compiled into the Flex]]></description>
			<content:encoded><![CDATA[<p>Utilizing the RSL (Runtime Shared Library) mechanism in Flex is arguably one of the quickest and easiest ways to <em>drastically</em> shrink your Flex application&#8217;s file size. The RSL mechanism essentially allows you to compile your Flex application without embedding the Flex framework into the code. So, if the Flex framework isn&#8217;t compiled into the Flex application (final SWF file), then how does the application work? The real genius comes in at this point&#8230; The Flash Player &#8211; as of version 9.0.60 &#8211; can now cache signed RSLs containing the Flex framework. If the Flash Player caches these frameworks, it means that if you have viewed a Flex site using the 3.2.0 SDK and you launch another Flex application using the same SDK, you do not have to download the whole framework from the server!</p>
<p>For more information and a brief tutorial, visit <a title="RSLs" href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs" target="_blank">this link</a> on the Adobe Labs site.</p>
<p>However, it&#8217;s not always as quick and easy as some might like to believe. Recently i&#8217;ve been playing around with RSLs and different versions of the Flex SDK and i&#8217;ve been encountering the dreaded <em><a title="RSL Error #1001" href="http://livedocs.adobe.com/flex/3/html/help.html?content=rsl_10.html" target="_blank">Error #1001</a></em> runtime error. This pernicious and convoluted little error can cause a spontaneous force of attraction between your forehead and your desk. It&#8217;s quite strange indeed&#8230; Well, after a bit of digging and some messing around, i seem to have noticed a general pattern for failure and subsequently getting the error message above, and how to fix it&#8230;</p>
<p>I&#8217;ve created a Flex project and have merrily gone about my day coding, styling, flexisizing etc&#8230; I&#8217;ve set my project to use RSLs (using the 3.2.0 Flex SDK) and everything is working just fine. Now i notice on the Adobe Labs site that there&#8217;s a new Flex SDK available (say&#8230; 3.3.0). I decide to chuck the current SDK and replace it with the new one&#8230; Only to see the following after a compile of the project:</p>
<p style="text-align: center;"><a title="EEEEEEEEEEEK!" rel="lightbox" href="http://ria-coder.com/temp/wp-content/uploads/2009/07/rsl-error.jpg"><img class="aligncenter size-full wp-image-356" title="rsl-error" src="http://ria-coder.com/temp/wp-content/uploads/2009/07/rsl-error.jpg" alt="rsl-error" width="400" height="299" /></a></p>
<p style="text-align: left;">Eek. Nothing like a good ol&#8217; spanner in the works, eh?</p>
<p style="text-align: left;">After a bit of scratching around in the 3.3.0 SDK folder, i came upon the <em>flex-config.xml</em> file (located at $FLEX_INSTALL_PATH/sdks/$SDK_VERSION/frameworks). If you scour through the file, you&#8217;ll see that towards the bottom there&#8217;s a node called <em>runtime-shared-library-path</em>. Here&#8217;s what it looks like in the 3.3.0 SDK:</p>
<pre>&lt;runtime-shared-library-path&gt;
	&lt;path-element&gt;libs/framework.swc&lt;/path-element&gt;
	&lt;rsl-url&gt;framework_3.3.0.4852.swz&lt;/rsl-url&gt;
	&lt;policy-file-url&gt;&lt;/policy-file-url&gt;
	&lt;rsl-url&gt;framework_3.3.0.4852.swf&lt;/rsl-url&gt;
	&lt;policy-file-url&gt;&lt;/policy-file-url&gt;
&lt;/runtime-shared-library-path&gt;</pre>
<p style="text-align: left;">Check out the two <em>rsl-url</em> properties&#8230; One is the name of a SWZ (signed SWF) file and the other is a plain SWF file&#8230; Notice the naming of those URLs and then refer back to the image above. Flex Builder obviously didn&#8217;t change the RSL linkages when i changed my SDK in my Flex project.</p>
<p style="text-align: left;"><strong>The SOLUTION:</strong></p>
<p style="text-align: left;">Open your Flex Project <em>Properties</em> dialog, select the <em>Flex Build Path</em> option on the left, then the <em>Library Path</em> tab at the top. You will then see something like this:</p>
<p style="text-align: left;"><a title="Flex Project Properties" rel="lightbox" href="http://ria-coder.com/temp/wp-content/uploads/2009/07/properties.png"><img class="alignleft size-medium wp-image-358" style="margin: 5px;" title="properties" src="http://ria-coder.com/blog/wp-content/uploads/2009/07/properties-300x269.png" alt="properties" width="300" height="269" /></a></p>
<p style="text-align: left;">Notice how the version numbers of the RSL files do not correlate with the version of Flex SDK? For some reason, Flex doesn&#8217;t change the RSL linkage when you switch SDKs in a Flex Project. I wonder whether this is a bug or a feature (like i often wonder about the <em>ON</em> button on Windows machines).</p>
<p style="text-align: left;">Anyway, the quick fix for this is as follows:</p>
<p style="text-align: left;">Simple select the Flex SDK and hit the <strong>REMOVE</strong> button on the right. The <strong>Add Flex SDK</strong> button will then become active and you can go ahead and click on it. This will scan the <em>flex-config.xml</em> file we looked at earlier and pick up the correct files to use for the RSL.</p>
<p style="text-align: left;">Done! You can now close the <em>Properties</em> dialog.</p>
<p style="text-align: left;">
<p style="text-align: left;">Go ahead and clean your project at this point by going to the menu, <em>Project</em> -&gt; <em>Clean</em>. This will delete all the compiled code that was previously generated and it will then trigger a new build. Once the build has completed, run your Flex application&#8230;</p>
<p style="text-align: left;">Oh, don&#8217;t you just love it when shit works?!</p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/runtime-shared-libraries-indispensable-and-infuriating/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Handling multiple remote services with RemoteObject &#8211; the easy way!</title>
		<link>http://ria-coder.com/blog/handling-multiple-remote-services-with-remoteobject-the-easy-way</link>
		<comments>http://ria-coder.com/blog/handling-multiple-remote-services-with-remoteobject-the-easy-way#comments</comments>
		<pubDate>Tue, 05 May 2009 22:16:03 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[amfphp]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[FaultEvent]]></category>
		<category><![CDATA[remoteobject]]></category>
		<category><![CDATA[ResultEvent]]></category>
		<category><![CDATA[service calls]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=271</guid>
		<description><![CDATA[Here's a quick and easy way to handle multiple service calls in two simple event handlers!]]></description>
			<content:encoded><![CDATA[<p>Ok, so you&#8217;re developing a Flex application with a bit of server-side integration (using PHP, Java, Ruby, .NET, etc) and your application is getting a little intense; multiple service calls to the server, custom logic for success and failure of said calls and everything in between.</p>
<p>You could use the following syntax for handling mutliple method-calls from a remote script (in this example <em>MyService</em>):</p>

<div class="wp_syntax"><table><tr><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
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RemoteObject</span> id=<span style="color: #ff0000;">&quot;service&quot;</span> destination=<span style="color: #ff0000;">&quot;amfphp&quot;</span> source=<span style="color: #ff0000;">&quot;MyService&quot;</span> makeObjectsBindable=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
 	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:method</span> name=<span style="color: #ff0000;">&quot;doSomething&quot;</span> result=<span style="color: #ff0000;">&quot;doSomethingResult(event)&quot;</span> fault=<span style="color: #ff0000;">&quot;doSomethingFault(event)&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
 	<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:method</span> name=<span style="color: #ff0000;">&quot;doAnotherSomething&quot;</span> result=<span style="color: #ff0000;">&quot;doAnotherSomethingResult(event)&quot;</span> fault=<span style="color: #ff0000;">&quot;doAnotherSomethingFault(event)&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:RemoteObject</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;"> 	&lt;![CDATA[</span>
<span style="color: #339933;">		private function doSomethingResult(event:ResultEvent):void</span>
<span style="color: #339933;">		{</span>
<span style="color: #339933;">			// custom logic</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		private function doSomethingFault(event:FaultEvent):void</span>
<span style="color: #339933;">		{</span>
<span style="color: #339933;">			// custom logic</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		private function doAnotherSomethingResult(event:ResultEvent):void</span>
<span style="color: #339933;">		{</span>
<span style="color: #339933;">			// custom logic</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		private function doAnotherSomethingFault(event:FaultEvent):void</span>
<span style="color: #339933;">		{</span>
<span style="color: #339933;">			// custom logic</span>
<span style="color: #339933;">		}</span>
<span style="color: #339933;"> 	]]&gt;</span>
<span style="color: #339933;">&lt;/mx:Script&gt;</span></pre></td></tr></table></div>

<p>I dunno about you, but to have to define <strong>special</strong> tags in MXML for each bloody method in your script is too much effort (and can leave you with some nasty/tricky bugs if you forget to add a new tag after adding a new method in your server-side script!). I used the following mechanism in my post about <a title="Integrating CodeIgniter, Flex and PHP" href="http://ria-coder.com/blog/integrating-flex-amfphp-and-codeigniter-with-value-objects/" target="_blank">integrating CodeIgniter, Flex and PHP</a> if i remember correctly&#8230; Give me a break&#8230; I was too lazy to check (it&#8217;s midnight and i&#8217;m sleepless).</p>

<div class="wp_syntax"><table><tr><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
</pre></td><td class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RemoteObject</span> id=<span style="color: #ff0000;">&quot;service&quot;</span> destination=<span style="color: #ff0000;">&quot;amfphp&quot;</span> source=<span style="color: #ff0000;">&quot;MyService&quot;</span> makeObjectsBindable=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #000000;">result=<span style="color: #ff0000;">&quot;resultHandler(event)&quot;</span> fault=<span style="color: #ff0000;">&quot;faultHandler(event)&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;"> 	&lt;![CDATA[</span>
<span style="color: #339933;">		private function resultHandler(event:ResultEvent):void</span>
<span style="color: #339933;">		{</span>
<span style="color: #339933;">			var message:RemotingMessage = event.token.message as RemotingMessage;</span>
&nbsp;
<span style="color: #339933;">			switch(message.operation)</span>
<span style="color: #339933;">			{</span>
<span style="color: #339933;">				case &quot;doSomething&quot;:</span>
<span style="color: #339933;">					// custom logic</span>
<span style="color: #339933;">					break;</span>
<span style="color: #339933;">				case &quot;doAnotherSomething&quot;:</span>
<span style="color: #339933;">					// custom logic</span>
<span style="color: #339933;">					break;</span>
<span style="color: #339933;">				default:</span>
<span style="color: #339933;">					trace(&quot;Shit... Missed this one... &quot; + message.operation);</span>
<span style="color: #339933;">					break;</span>
<span style="color: #339933;">			}</span>
<span style="color: #339933;">		}</span>
&nbsp;
<span style="color: #339933;">		private function faultHandler(event:FaultEvent):void</span>
<span style="color: #339933;">		{</span>
<span style="color: #339933;">			var message:RemotingMessage = event.token.message as RemotingMessage;</span>
&nbsp;
<span style="color: #339933;">			switch(message.operation)</span>
<span style="color: #339933;">			{</span>
<span style="color: #339933;">				case &quot;doSomething&quot;:</span>
<span style="color: #339933;">					// custom logic</span>
<span style="color: #339933;">					break;</span>
<span style="color: #339933;">				case &quot;doAnotherSomething&quot;:</span>
<span style="color: #339933;">					// custom logic</span>
<span style="color: #339933;">					break;</span>
<span style="color: #339933;">				default:</span>
<span style="color: #339933;">					trace(&quot;Shit... Missed this one... &quot; + message.operation);</span>
<span style="color: #339933;">					break;</span>
<span style="color: #339933;">			}</span>
<span style="color: #339933;">		}</span>
<span style="color: #339933;"> 	]]&gt;</span>
<span style="color: #339933;">&lt;/mx:Script&gt;</span></pre></td></tr></table></div>

<p>Seems much easier, doesn&#8217;t it? Essentially all you&#8217;re doing is examining the event parameter of the ResultEvent or FaultEvent, finding which method was just called and acting accordingly&#8230; This will work with any number of method calls, from any number of different RemoteObjects. You can point them all to the same handlers!</p>
<p>If you guys have any alternative ways of doing this, let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/handling-multiple-remote-services-with-remoteobject-the-easy-way/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
