<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Building a simple Flex module</title>
	<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Fri, 05 Dec 2008 11:37:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Allen</title>
		<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-16931</link>
		<author>Allen</author>
		<pubDate>Thu, 27 Nov 2008 13:17:08 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-16931</guid>
		<description>Hi,Petter!
I come from China too,thank you for your tutals,but I still have diffficult in understanding modules applications.Using modules can decrease the file size of our swf,but Runtime Share can also do,what's different between them,and what time should use the module?
Thank you!</description>
		<content:encoded><![CDATA[<p>Hi,Petter!<br />
I come from China too,thank you for your tutals,but I still have diffficult in understanding modules applications.Using modules can decrease the file size of our swf,but Runtime Share can also do,what&#8217;s different between them,and what time should use the module?<br />
Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saul</title>
		<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-16811</link>
		<author>saul</author>
		<pubDate>Thu, 20 Nov 2008 17:36:12 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-16811</guid>
		<description>i don't think its on adobes priority list for flash player 10s unloadAndStop method.

So Let me just test...

...10 mins later.

Thats interesting i took the 3d as3 geom model away and left the plane with a bitmap on it. When i clicked in and out to load/unload the memory rose to about 250mb then it started to drop and level off at 230 (i am reading the memory through windows task manager), i think unloadAndStop and gc set to true is doing its job(s) but gc took a little time to kick in. It didn't go back to the original main app weight of about 170mb ram on first load either, which gives me a little concern that there is initial memory leakage or perhaps gc allocates a suitable byte allocation block on the flash player to that level after its loaded up everything?!

Most importantly though the ram stabilised and even came back down a little. So its the 3d model thats the culprit i think!

I've tried using the memory profiler in flex to look into this also but cannot get that to work - don't ask - so i don't know exactly but its becoming clear
that the 3d model is still being referenced and maybe the skin to.

Can you please help me with this problem.

Help me define it and solve it. What is this problem exactly. Why is UnloadAndStop() not terminating the references/listeners generated by the 3d model on the loaded swf.

Is the loaded swf reversing the referencing logic through EventDispatcher.

How can I terminate the references and from where, which app, main or loaded.

Pls help me.</description>
		<content:encoded><![CDATA[<p>i don&#8217;t think its on adobes priority list for flash player 10s unloadAndStop method.</p>
<p>So Let me just test&#8230;</p>
<p>&#8230;10 mins later.</p>
<p>Thats interesting i took the 3d as3 geom model away and left the plane with a bitmap on it. When i clicked in and out to load/unload the memory rose to about 250mb then it started to drop and level off at 230 (i am reading the memory through windows task manager), i think unloadAndStop and gc set to true is doing its job(s) but gc took a little time to kick in. It didn&#8217;t go back to the original main app weight of about 170mb ram on first load either, which gives me a little concern that there is initial memory leakage or perhaps gc allocates a suitable byte allocation block on the flash player to that level after its loaded up everything?!</p>
<p>Most importantly though the ram stabilised and even came back down a little. So its the 3d model thats the culprit i think!</p>
<p>I&#8217;ve tried using the memory profiler in flex to look into this also but cannot get that to work - don&#8217;t ask - so i don&#8217;t know exactly but its becoming clear<br />
that the 3d model is still being referenced and maybe the skin to.</p>
<p>Can you please help me with this problem.</p>
<p>Help me define it and solve it. What is this problem exactly. Why is UnloadAndStop() not terminating the references/listeners generated by the 3d model on the loaded swf.</p>
<p>Is the loaded swf reversing the referencing logic through EventDispatcher.</p>
<p>How can I terminate the references and from where, which app, main or loaded.</p>
<p>Pls help me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saul</title>
		<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-16810</link>
		<author>saul</author>
		<pubDate>Thu, 20 Nov 2008 17:34:20 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-16810</guid>
		<description>..I have managed to load child apps/swfs into the main app using SWFLoader. Testing went well with two browser exceptions (opera and chrome).

However, they all failed on

...The problem: When the swf is unloaded the ram used (lets say 30 mb) stays. As the swfs load and unload without the ram being taken back that ram keeps going up. A ram/gc/listener/referencing/EventDispatcher problem?

Using unloadAndStop(true) sorted out the cpu usage that unload and FP9 were not doing, which is interesting because cpu usage goes to 0 on unloading so are my loaded swfs/references/listeners getting unloaded/killed properly...Well they can't be.

The garbage collector does not free any of the ram that is used to render the loaded swf (the swf contains 3d data as described above).

The TriangleMesh3D is still being referenced </description>
		<content:encoded><![CDATA[<p>..I have managed to load child apps/swfs into the main app using SWFLoader. Testing went well with two browser exceptions (opera and chrome).</p>
<p>However, they all failed on</p>
<p>&#8230;The problem: When the swf is unloaded the ram used (lets say 30 mb) stays. As the swfs load and unload without the ram being taken back that ram keeps going up. A ram/gc/listener/referencing/EventDispatcher problem?</p>
<p>Using unloadAndStop(true) sorted out the cpu usage that unload and FP9 were not doing, which is interesting because cpu usage goes to 0 on unloading so are my loaded swfs/references/listeners getting unloaded/killed properly&#8230;Well they can&#8217;t be.</p>
<p>The garbage collector does not free any of the ram that is used to render the loaded swf (the swf contains 3d data as described above).</p>
<p>The TriangleMesh3D is still being referenced</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saul</title>
		<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-16809</link>
		<author>saul</author>
		<pubDate>Thu, 20 Nov 2008 17:31:41 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-16809</guid>
		<description>The person above aka mor.on who wrote this, me says...

...SORRY Peter!

I was irrational and wrong, well kinda.

unloadandStop missing TriangleMesh3D

I am using Gumbo 4.0 SDK - Flex Project, targeting FP10.

I am using a simple states based model (using enterstate and mouseclick events to execute the loading and unloading of swfs into my main application (aState) at runtime). If i had more time and researched better in the first place i may have invested in a better mvc strategy.

I am loading papervision3d swfs created in flex mxml/as3.

The 3d models i use are made with as3 geom and are classes that extend TriangleMesh3D and use jpg skins using the embed/class technique.

(TriangleMesh3D Inherits from: Vertices3D 








.................................................. .....
.................................................. .....

Here is the code of the incoming SWF:










..............................................
..............................................

Here is a code portion of the 3d car model class

package objects
{
import org.papervision3d.core.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.core.geom.renderables.Triangle3D ;
import org.papervision3d.core.geom.renderables.Vertex3D;
import org.papervision3d.core.math.NumberUV;
import org.papervision3d.core.proto.*;

public class CarFinal extends TriangleMesh3D
{

public var verts :Array;
public var faceAr:Array;
public var uvs :Array;

private function v(x:Number,y:Number,z:Number):void
{
verts.push(new Vertex3D(x,y,z));
}

private function uv(u:Number,v:Number):void
{
uvs.push(new NumberUV(u,v));
}

private function f(vn0:int, vn1:int, vn2:int, uvn0:int, uvn1:int,uvn2:int):void
{
faceAr.push( new Triangle3D( this, [verts[vn0],verts[vn1],verts[vn2] ], null, [uvs[uvn0],uvs[uvn1],uvs[uvn2]] ) );
}

public function cobraCarFinal( material:MaterialObject3D=null, initObject:Object=null )
{
super( material, new Array(), new Array(), null );
verts = this.geometry.vertices;
faceAr= this.geometry.faces;
uvs =new Array();
v(108.544,-31.9748,-101.242);
...........................
f(1248,5195,5196,1248,5195,5196);
this.geometry.ready = true;
}

}

}</description>
		<content:encoded><![CDATA[<p>The person above aka mor.on who wrote this, me says&#8230;</p>
<p>&#8230;SORRY Peter!</p>
<p>I was irrational and wrong, well kinda.</p>
<p>unloadandStop missing TriangleMesh3D</p>
<p>I am using Gumbo 4.0 SDK - Flex Project, targeting FP10.</p>
<p>I am using a simple states based model (using enterstate and mouseclick events to execute the loading and unloading of swfs into my main application (aState) at runtime). If i had more time and researched better in the first place i may have invested in a better mvc strategy.</p>
<p>I am loading papervision3d swfs created in flex mxml/as3.</p>
<p>The 3d models i use are made with as3 geom and are classes that extend TriangleMesh3D and use jpg skins using the embed/class technique.</p>
<p>(TriangleMesh3D Inherits from: Vertices3D </p>
<p>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. &#8230;..<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. &#8230;..</p>
<p>Here is the code of the incoming SWF:</p>
<p>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</p>
<p>Here is a code portion of the 3d car model class</p>
<p>package objects<br />
{<br />
import org.papervision3d.core.*;<br />
import org.papervision3d.core.geom.*;<br />
import org.papervision3d.core.geom.renderables.Triangle3D ;<br />
import org.papervision3d.core.geom.renderables.Vertex3D;<br />
import org.papervision3d.core.math.NumberUV;<br />
import org.papervision3d.core.proto.*;</p>
<p>public class CarFinal extends TriangleMesh3D<br />
{</p>
<p>public var verts :Array;<br />
public var faceAr:Array;<br />
public var uvs :Array;</p>
<p>private function v(x:Number,y:Number,z:Number):void<br />
{<br />
verts.push(new Vertex3D(x,y,z));<br />
}</p>
<p>private function uv(u:Number,v:Number):void<br />
{<br />
uvs.push(new NumberUV(u,v));<br />
}</p>
<p>private function f(vn0:int, vn1:int, vn2:int, uvn0:int, uvn1:int,uvn2:int):void<br />
{<br />
faceAr.push( new Triangle3D( this, [verts[vn0],verts[vn1],verts[vn2] ], null, [uvs[uvn0],uvs[uvn1],uvs[uvn2]] ) );<br />
}</p>
<p>public function cobraCarFinal( material:MaterialObject3D=null, initObject:Object=null )<br />
{<br />
super( material, new Array(), new Array(), null );<br />
verts = this.geometry.vertices;<br />
faceAr= this.geometry.faces;<br />
uvs =new Array();<br />
v(108.544,-31.9748,-101.242);<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<br />
f(1248,5195,5196,1248,5195,5196);<br />
this.geometry.ready = true;<br />
}</p>
<p>}</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saul</title>
		<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-16789</link>
		<author>saul</author>
		<pubDate>Wed, 19 Nov 2008 14:45:25 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-16789</guid>
		<description>What i've realised about flex is that as a concept it has been mis-sold.

Flex has been sold to developers and designers as a tool that offers a great deal of flexibility and ease of use, abstracting out, particularly with respect to visual components, many of the more difficult aspects of flash gui design.

This is a useless example Peter because the most important aspect about modules and flex into flex is unloading and garbage collection.

I'm really upset at the moment because i have spent 3 months building my first flex app (something i realise i could have done nearly as well in 2 weeks using html and elements of flash) and i'm stuck.

I'm stuck because i'm building an app that loads swfs into it using swfloader. I'm stuck because the mythical moses like unloadAndStop isn't cutting it. I'm stuck because memory just keeps rocketing up and gc is anarchic. The gc hacks don't work for me. Also, Flex is really tough and really buggy. Its like a year or two from actually working properly.

I'm so dissolusioned with flex at the moment Peter. And, am viewing you and people who are responsible for marketing this tool as nothing more than doorstep salespeople.

Why should i have to recreate the wheel to get the darn thing to give me back the memory. I'm not interested in the inner workings of the flash player. I'm not interested in cairngorm or mvc. That was never the promise.

Peter can you pls, if you really care about this thing, show me how to unload an swf and have it give back the memory. I don't care if its done through moduleloader or swfloader or loader. I could not care less at the moment. Ideally it would be through swfloader. Or, simple educate me on whether this can be done relatively easily with swfloader and what approach is best for people who are not as3 rocket scientists! Roger that.</description>
		<content:encoded><![CDATA[<p>What i&#8217;ve realised about flex is that as a concept it has been mis-sold.</p>
<p>Flex has been sold to developers and designers as a tool that offers a great deal of flexibility and ease of use, abstracting out, particularly with respect to visual components, many of the more difficult aspects of flash gui design.</p>
<p>This is a useless example Peter because the most important aspect about modules and flex into flex is unloading and garbage collection.</p>
<p>I&#8217;m really upset at the moment because i have spent 3 months building my first flex app (something i realise i could have done nearly as well in 2 weeks using html and elements of flash) and i&#8217;m stuck.</p>
<p>I&#8217;m stuck because i&#8217;m building an app that loads swfs into it using swfloader. I&#8217;m stuck because the mythical moses like unloadAndStop isn&#8217;t cutting it. I&#8217;m stuck because memory just keeps rocketing up and gc is anarchic. The gc hacks don&#8217;t work for me. Also, Flex is really tough and really buggy. Its like a year or two from actually working properly.</p>
<p>I&#8217;m so dissolusioned with flex at the moment Peter. And, am viewing you and people who are responsible for marketing this tool as nothing more than doorstep salespeople.</p>
<p>Why should i have to recreate the wheel to get the darn thing to give me back the memory. I&#8217;m not interested in the inner workings of the flash player. I&#8217;m not interested in cairngorm or mvc. That was never the promise.</p>
<p>Peter can you pls, if you really care about this thing, show me how to unload an swf and have it give back the memory. I don&#8217;t care if its done through moduleloader or swfloader or loader. I could not care less at the moment. Ideally it would be through swfloader. Or, simple educate me on whether this can be done relatively easily with swfloader and what approach is best for people who are not as3 rocket scientists! Roger that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pascal</title>
		<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-13597</link>
		<author>Pascal</author>
		<pubDate>Mon, 23 Jun 2008 16:14:41 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-13597</guid>
		<description>Is there a way to load an MXML module compiled SWF into an actionscript only project?</description>
		<content:encoded><![CDATA[<p>Is there a way to load an MXML module compiled SWF into an actionscript only project?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan D.</title>
		<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-13222</link>
		<author>Dan D.</author>
		<pubDate>Wed, 04 Jun 2008 15:25:05 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-13222</guid>
		<description>Thank you for this very handy example.  It was very useful for me while implementing Flex modules.</description>
		<content:encoded><![CDATA[<p>Thank you for this very handy example.  It was very useful for me while implementing Flex modules.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: prasanth</title>
		<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-12762</link>
		<author>prasanth</author>
		<pubDate>Mon, 19 May 2008 05:39:56 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-12762</guid>
		<description>Hey thanks a lot Peter for the snippet .It worked for me.</description>
		<content:encoded><![CDATA[<p>Hey thanks a lot Peter for the snippet .It worked for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vito</title>
		<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-12755</link>
		<author>Vito</author>
		<pubDate>Sun, 18 May 2008 07:19:36 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-12755</guid>
		<description>To answer Joe's question:
Module vs. Application
I turned the VideoModule into an application by just changing the module tags and then loaded it via a swf loader in the main.mxml application. 

What happens is your module and main application aren't able to talk to each other as easily anymore. Not to mention the size of a module is about 10 times smaller than a application. You have to load all the application framework if you swf load an app but you don't have to do that if you load a module.

Size differences:
[SWF] VideoApp.swf - 624,958 bytes after decompression
[SWF] ApplicationLoader.swf - 681,000 bytes after decompression

[SWF] VideoModule.swf - 63,301 bytes after decompression
[SWF] main.swf - 670,323 bytes after decompression

You can also use modules as building blocks in one application to make a modular application.</description>
		<content:encoded><![CDATA[<p>To answer Joe&#8217;s question:<br />
Module vs. Application<br />
I turned the VideoModule into an application by just changing the module tags and then loaded it via a swf loader in the main.mxml application. </p>
<p>What happens is your module and main application aren&#8217;t able to talk to each other as easily anymore. Not to mention the size of a module is about 10 times smaller than a application. You have to load all the application framework if you swf load an app but you don&#8217;t have to do that if you load a module.</p>
<p>Size differences:<br />
[SWF] VideoApp.swf - 624,958 bytes after decompression<br />
[SWF] ApplicationLoader.swf - 681,000 bytes after decompression</p>
<p>[SWF] VideoModule.swf - 63,301 bytes after decompression<br />
[SWF] main.swf - 670,323 bytes after decompression</p>
<p>You can also use modules as building blocks in one application to make a modular application.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-12582</link>
		<author>peterd</author>
		<pubDate>Fri, 09 May 2008 15:27:18 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-12582</guid>
		<description>&lt;a href="http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-12573" rel="nofollow"&gt;prasanth&lt;/a&gt;,

Does this snippet work for you?
&lt;pre class="code"&gt;
&lt;strong style="color:red;"&gt;&#60;mx:WipeDown id=&#34;wipeEffect&#34; duration=&#34;6000&#34; /&#62;&lt;/strong&gt;

&#60;mx:Panel id=&#34;panel&#34;
        title=&#34;Module: {moduleTitle}&#34;&#62;
    &#60;mx:ModuleLoader id=&#34;m1&#34;
            url=&#34;VideoModule.swf&#34;
            ready=&#34;init(); &lt;strong style="color:red;"&gt;wipeEffect.play([m1]);&#34;&lt;/strong&gt; /&#62;
&lt;/pre&gt;

Basically it uses the &lt;code&gt;ready&lt;/code&gt; event to play a wipe effect.

Peter</description>
		<content:encoded><![CDATA[<p><a href="http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/#comment-12573" rel="nofollow">prasanth</a>,</p>
<p>Does this snippet work for you?</p>
<pre class="code">
<strong style="color:red;">&lt;mx:WipeDown id=&quot;wipeEffect&quot; duration=&quot;6000&quot; /&gt;</strong>

&lt;mx:Panel id=&quot;panel&quot;
        title=&quot;Module: {moduleTitle}&quot;&gt;
    &lt;mx:ModuleLoader id=&quot;m1&quot;
            url=&quot;VideoModule.swf&quot;
            ready=&quot;init(); <strong style="color:red;">wipeEffect.play([m1]);&quot;</strong> /&gt;
</pre>
<p>Basically it uses the <code>ready</code> event to play a wipe effect.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
</channel>
</rss>
