<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: Loading a Remote Module into a Local App</title>
	<atom:link href="http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/feed/" rel="self" type="application/rss+xml" />
	<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/</link>
	<description>For all your Aaron Hardy needs.</description>
	<lastBuildDate>Tue, 17 Jan 2012 03:38:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Aaron Hardy</title>
		<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/comment-page-1/#comment-37359</link>
		<dc:creator>Aaron Hardy</dc:creator>
		<pubDate>Thu, 12 Jan 2012 16:01:31 +0000</pubDate>
		<guid isPermaLink="false">http://aaronhardy.com/?p=295#comment-37359</guid>
		<description>Hey Maurice.  I remember working with runtime fonts a couple years back and I ran into a bunch of problems.  Not so much loading the font, but getting the font swf right and registering it correctly.  You can see a chronology of my battle here:

http://forums.adobe.com/thread/465439

I know I used several articles to help me figure it out.  One of them is no longer available.  I think this is a good one: http://bit.ly/4FyegT

I hope you find what you need.</description>
		<content:encoded><![CDATA[<p>Hey Maurice.  I remember working with runtime fonts a couple years back and I ran into a bunch of problems.  Not so much loading the font, but getting the font swf right and registering it correctly.  You can see a chronology of my battle here:</p>
<p><a href="http://forums.adobe.com/thread/465439" rel="nofollow">http://forums.adobe.com/thread/465439</a></p>
<p>I know I used several articles to help me figure it out.  One of them is no longer available.  I think this is a good one: <a href="http://bit.ly/4FyegT" rel="nofollow">http://bit.ly/4FyegT</a></p>
<p>I hope you find what you need.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maurice</title>
		<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/comment-page-1/#comment-37336</link>
		<dc:creator>Maurice</dc:creator>
		<pubDate>Thu, 12 Jan 2012 08:47:57 +0000</pubDate>
		<guid isPermaLink="false">http://aaronhardy.com/?p=295#comment-37336</guid>
		<description>I am trying to use StyleModuleMarshallers to load an external swf with a font embedded (css converted into swf) in Flex 4.5.

In the modReadyHandler i can see it gets the font (event.currentTarget.factory._info.fonts).

Could you tell me how i can then do a Font.registerFont(font)? 

Any help would be appreciated. Also the strange thing, in debug locally it works but when i put the app online it generates an error: Error #2044: IOErrorEvent:. text=Error #2124: Loaded file is unknown type. 

Thanx!</description>
		<content:encoded><![CDATA[<p>I am trying to use StyleModuleMarshallers to load an external swf with a font embedded (css converted into swf) in Flex 4.5.</p>
<p>In the modReadyHandler i can see it gets the font (event.currentTarget.factory._info.fonts).</p>
<p>Could you tell me how i can then do a Font.registerFont(font)? </p>
<p>Any help would be appreciated. Also the strange thing, in debug locally it works but when i put the app online it generates an error: Error #2044: IOErrorEvent:. text=Error #2124: Loaded file is unknown type. </p>
<p>Thanx!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chuck</title>
		<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/comment-page-1/#comment-37020</link>
		<dc:creator>Chuck</dc:creator>
		<pubDate>Fri, 06 Jan 2012 19:36:32 +0000</pubDate>
		<guid isPermaLink="false">http://aaronhardy.com/?p=295#comment-37020</guid>
		<description>I wasn&#039;t able to get StyleModuleMarshaller to actually apply the loaded styles to the app. I found I needed to add a call to loadStyleDeclarations in the modReadyHandler override in order to actually get them applied.

// Even though the url is passed in, it&#039;s not going to re-fetch/load the module,
// so there&#039;s no unnecessary performance penalty. 
mx.core.Singleton.getInstance(&quot;mx.styles::IStyleManager2&quot;).loadStyleDeclarations2(url, updateStylesImmediately, null, null);

As I note in the comment, I debugged and verified that the module isn&#039;t actually being refetched, since the ModuleManager singleton maintains a map of all requested URLs and their loaded modules.

Just floating this out there in case anyone else is trying to use StyleModuleMarshaller without success.</description>
		<content:encoded><![CDATA[<p>I wasn&#8217;t able to get StyleModuleMarshaller to actually apply the loaded styles to the app. I found I needed to add a call to loadStyleDeclarations in the modReadyHandler override in order to actually get them applied.</p>
<p>// Even though the url is passed in, it&#8217;s not going to re-fetch/load the module,<br />
// so there&#8217;s no unnecessary performance penalty.<br />
mx.core.Singleton.getInstance(&#8220;mx.styles::IStyleManager2&#8243;).loadStyleDeclarations2(url, updateStylesImmediately, null, null);</p>
<p>As I note in the comment, I debugged and verified that the module isn&#8217;t actually being refetched, since the ModuleManager singleton maintains a map of all requested URLs and their loaded modules.</p>
<p>Just floating this out there in case anyone else is trying to use StyleModuleMarshaller without success.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitry</title>
		<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/comment-page-1/#comment-33672</link>
		<dc:creator>Dmitry</dc:creator>
		<pubDate>Sat, 12 Nov 2011 01:48:19 +0000</pubDate>
		<guid isPermaLink="false">http://aaronhardy.com/?p=295#comment-33672</guid>
		<description>&quot;Likewise it doesn&#039;t call a crossdomain automatically either.&quot; - Good catch. Thanks, it&#039;s now clear.
I&#039;ll do the same, while AIR is still breathing...</description>
		<content:encoded><![CDATA[<p>&#8220;Likewise it doesn&#8217;t call a crossdomain automatically either.&#8221; &#8211; Good catch. Thanks, it&#8217;s now clear.<br />
I&#8217;ll do the same, while AIR is still breathing&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Hardy</title>
		<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/comment-page-1/#comment-33671</link>
		<dc:creator>Aaron Hardy</dc:creator>
		<pubDate>Sat, 12 Nov 2011 01:44:51 +0000</pubDate>
		<guid isPermaLink="false">http://aaronhardy.com/?p=295#comment-33671</guid>
		<description>See here: http://bugs.adobe.com/jira/browse/SDK-15393</description>
		<content:encoded><![CDATA[<p>See here: <a href="http://bugs.adobe.com/jira/browse/SDK-15393" rel="nofollow">http://bugs.adobe.com/jira/browse/SDK-15393</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitry</title>
		<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/comment-page-1/#comment-33670</link>
		<dc:creator>Dmitry</dc:creator>
		<pubDate>Sat, 12 Nov 2011 01:37:29 +0000</pubDate>
		<guid isPermaLink="false">http://aaronhardy.com/?p=295#comment-33670</guid>
		<description>So, then why not to go with crossdomain.xml solution? Much easier then code around module.load(), right? I&#039;m just not getting rationale why webserver + crossdomain.xml is not a viable solution for your case.</description>
		<content:encoded><![CDATA[<p>So, then why not to go with crossdomain.xml solution? Much easier then code around module.load(), right? I&#8217;m just not getting rationale why webserver + crossdomain.xml is not a viable solution for your case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Hardy</title>
		<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/comment-page-1/#comment-33657</link>
		<dc:creator>Aaron Hardy</dc:creator>
		<pubDate>Fri, 11 Nov 2011 20:38:30 +0000</pubDate>
		<guid isPermaLink="false">http://aaronhardy.com/?p=295#comment-33657</guid>
		<description>No, I wanted to load them from a remote server.  How to do so is the topic of this post.</description>
		<content:encoded><![CDATA[<p>No, I wanted to load them from a remote server.  How to do so is the topic of this post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitry</title>
		<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/comment-page-1/#comment-33654</link>
		<dc:creator>Dmitry</dc:creator>
		<pubDate>Fri, 11 Nov 2011 20:13:41 +0000</pubDate>
		<guid isPermaLink="false">http://aaronhardy.com/?p=295#comment-33654</guid>
		<description>&quot;However, my workflow is to NOT have a local web hosting server running and I don’t want to have one running just to get around these errors.&quot;

Don&#039;t you need one (Apache or Tomcat) to load your modules or resource bundles anyway?</description>
		<content:encoded><![CDATA[<p>&#8220;However, my workflow is to NOT have a local web hosting server running and I don’t want to have one running just to get around these errors.&#8221;</p>
<p>Don&#8217;t you need one (Apache or Tomcat) to load your modules or resource bundles anyway?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davis</title>
		<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/comment-page-1/#comment-24596</link>
		<dc:creator>Davis</dc:creator>
		<pubDate>Wed, 22 Jun 2011 03:48:53 +0000</pubDate>
		<guid isPermaLink="false">http://aaronhardy.com/?p=295#comment-24596</guid>
		<description>Follow-up -- I was able to solve this particular issue, by loading the module in actionscript passing the ByteArray.  I did not end up using your ModuleMarshaller, but I assume we work around the same problem by passing in the byte array.  For example:

// load the swf into a byte array
var bytes:ByteArray = new ByteArray();
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE,
	function(evt:Event):void {
		bytes = ByteArray(evt.target.data);
		moduleLoader.loadModule(url, bytes);
	}
);
					
// LOAD IT
urlLoader.load(new URLRequest(url)); 

But this *STILL* doesn&#039;t solve all the issues.  The ModuleEvent.READY event does not always fire.  It seems like something gets garbage collected, and the event is lost most of the time.  If I step debug it into the framework code, I can make it work, but if I run w/o breakpoints the event never fires.

There have been lots of bugs filed against Adobe for this:

http://bugs.adobe.com/jira/browse/SDK-14669
http://bugs.adobe.com/jira/browse/SDK-24343

Those are just two -- I think there are others.  I&#039;m aghast that this issue still hasn&#039;t been fixed in 4.5 SDK.  Here&#039;s the workaround:

Instead of adding an event listener to the ModuleLoader for ModuleEvent.READY, add it to the IModuleInfo object in the ModuleEvent.SETUP...example:

var moduleLoader:ModuleLoader = new ModuleLoader();

// DON&#039;T DO THE FIRST ONE					
//moduleLoader.addEventListener(ModuleEvent.READY, onReady);
moduleLoader.addEventListener(ModuleEvent.ERROR, onError);
moduleLoader.addEventListener(ModuleEvent.PROGRESS, onProgress);
moduleLoader.addEventListener(ModuleEvent.SETUP, onSetup);
moduleLoader.addEventListener(ModuleEvent.UNLOAD, onUnload);
moduleLoader.addEventListener(mx.events.FlexEvent.LOADING, onLoading);
moduleLoader.addEventListener(mx.events.FlexEvent.URL_CHANGED, onUrlChanged);

Now, look at the onSetup handler:

private var moduleInfo:IModuleInfo;  // save a ref so it won&#039;t get GC&#039;d

private function onSetup(evt:ModuleEvent):void { 
	LOG.info(&quot;Module was initialized&quot;);
	moduleInfo = evt.module;
	moduleInfo.addEventListener(ModuleEvent.READY, onReady);
	moduleInfo.addEventListener(ModuleEvent.ERROR, onError);
}

Now, ModuleEvent.READY seems to always fire consistently, and then you can add the content as a child to some other container:

private function onReady(evt:ModuleEvent):void {
	LOG.info(&quot;Module is ready&quot;);
	var info:IModuleInfo = evt.module;
	var obj:Object = info.factory.create();
	border.addElement(obj as IVisualElement);
}

I hope this helps somebody!  I just wasted a lot of hours on it.</description>
		<content:encoded><![CDATA[<p>Follow-up &#8212; I was able to solve this particular issue, by loading the module in actionscript passing the ByteArray.  I did not end up using your ModuleMarshaller, but I assume we work around the same problem by passing in the byte array.  For example:</p>
<p>// load the swf into a byte array<br />
var bytes:ByteArray = new ByteArray();<br />
var urlLoader:URLLoader = new URLLoader();<br />
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;<br />
urlLoader.addEventListener(Event.COMPLETE,<br />
	function(evt:Event):void {<br />
		bytes = ByteArray(evt.target.data);<br />
		moduleLoader.loadModule(url, bytes);<br />
	}<br />
);</p>
<p>// LOAD IT<br />
urlLoader.load(new URLRequest(url)); </p>
<p>But this *STILL* doesn&#8217;t solve all the issues.  The ModuleEvent.READY event does not always fire.  It seems like something gets garbage collected, and the event is lost most of the time.  If I step debug it into the framework code, I can make it work, but if I run w/o breakpoints the event never fires.</p>
<p>There have been lots of bugs filed against Adobe for this:</p>
<p><a href="http://bugs.adobe.com/jira/browse/SDK-14669" rel="nofollow">http://bugs.adobe.com/jira/browse/SDK-14669</a><br />
<a href="http://bugs.adobe.com/jira/browse/SDK-24343" rel="nofollow">http://bugs.adobe.com/jira/browse/SDK-24343</a></p>
<p>Those are just two &#8212; I think there are others.  I&#8217;m aghast that this issue still hasn&#8217;t been fixed in 4.5 SDK.  Here&#8217;s the workaround:</p>
<p>Instead of adding an event listener to the ModuleLoader for ModuleEvent.READY, add it to the IModuleInfo object in the ModuleEvent.SETUP&#8230;example:</p>
<p>var moduleLoader:ModuleLoader = new ModuleLoader();</p>
<p>// DON&#8217;T DO THE FIRST ONE<br />
//moduleLoader.addEventListener(ModuleEvent.READY, onReady);<br />
moduleLoader.addEventListener(ModuleEvent.ERROR, onError);<br />
moduleLoader.addEventListener(ModuleEvent.PROGRESS, onProgress);<br />
moduleLoader.addEventListener(ModuleEvent.SETUP, onSetup);<br />
moduleLoader.addEventListener(ModuleEvent.UNLOAD, onUnload);<br />
moduleLoader.addEventListener(mx.events.FlexEvent.LOADING, onLoading);<br />
moduleLoader.addEventListener(mx.events.FlexEvent.URL_CHANGED, onUrlChanged);</p>
<p>Now, look at the onSetup handler:</p>
<p>private var moduleInfo:IModuleInfo;  // save a ref so it won&#8217;t get GC&#8217;d</p>
<p>private function onSetup(evt:ModuleEvent):void {<br />
	LOG.info(&#8220;Module was initialized&#8221;);<br />
	moduleInfo = evt.module;<br />
	moduleInfo.addEventListener(ModuleEvent.READY, onReady);<br />
	moduleInfo.addEventListener(ModuleEvent.ERROR, onError);<br />
}</p>
<p>Now, ModuleEvent.READY seems to always fire consistently, and then you can add the content as a child to some other container:</p>
<p>private function onReady(evt:ModuleEvent):void {<br />
	LOG.info(&#8220;Module is ready&#8221;);<br />
	var info:IModuleInfo = evt.module;<br />
	var obj:Object = info.factory.create();<br />
	border.addElement(obj as IVisualElement);<br />
}</p>
<p>I hope this helps somebody!  I just wasted a lot of hours on it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davis</title>
		<link>http://aaronhardy.com/flex/loading-a-remote-module-into-a-local-app/comment-page-1/#comment-24594</link>
		<dc:creator>Davis</dc:creator>
		<pubDate>Wed, 22 Jun 2011 03:04:17 +0000</pubDate>
		<guid isPermaLink="false">http://aaronhardy.com/?p=295#comment-24594</guid>
		<description>Dang!  I just got hit with this myself, and debugged it into the same area you indicate in ModuleManager.as using the latest and greatest SDK 4.5.

FYI: I just posted this question to flexcoders mailing list, but I&#039;m not holding out for a solid answer...

http://tech.groups.yahoo.com/group/flexcoders/message/162771

It sux that this hasn&#039;t been fixed.  Note that in my case, I&#039;m trying to load a SWF from the local file system into an Air app.  Hence: it would seem bizarre if security constraints would be the root cause of the issue here.</description>
		<content:encoded><![CDATA[<p>Dang!  I just got hit with this myself, and debugged it into the same area you indicate in ModuleManager.as using the latest and greatest SDK 4.5.</p>
<p>FYI: I just posted this question to flexcoders mailing list, but I&#8217;m not holding out for a solid answer&#8230;</p>
<p><a href="http://tech.groups.yahoo.com/group/flexcoders/message/162771" rel="nofollow">http://tech.groups.yahoo.com/group/flexcoders/message/162771</a></p>
<p>It sux that this hasn&#8217;t been fixed.  Note that in my case, I&#8217;m trying to load a SWF from the local file system into an Air app.  Hence: it would seem bizarre if security constraints would be the root cause of the issue here.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

