tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/1112-robotlegs-152-compiling-modules-as-swfs-in-flasbuilderRobotlegs: Discussion 2012-10-04T16:56:33Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/192768842012-10-04T11:51:00Z2012-10-04T11:51:00ZRobotlegs 1.5.2 : Compiling Modules as swf's<div><p>Hi Thomas!</p>
<p>“When you set up your project's architecture, you can
decide to include modules in your application's project, create a
separate project for each module, or create a separate project for
all modules…. If the modules are in the same project as your
Flex application, then when you run your application, Flex Builder
compiles the modules' SWF files for you.” [source first link
bellow]</p>
<p><strong>Compile a single module’s project</strong></p>
<ol>
<li>Right-click the module’s MXML file in the module’s
project.</li>
<li>Select Run Application. The Player or browser window tries to
run the module after it is compiled. You can close the Player or
browser window and ignore any error messages that appear at
runtime. Modules are not meant to be run in the Player or in a
browser directly.</li>
</ol>
<p><strong>Recompiling modules</strong></p>
<p>If you change a module, you do not have to recompile the
application that uses the module if that module is in the same
project. This is because the application loads the module at run
time and does not check against it at compile time. Similarly, if
you make changes to the application, you do not have to recompile
the module. Just as the application does not check against the
module at compile time, the module does not check against the
application until run time.<br>
If the module is in a separate project than the application that
loads it, you must recompile the module separately. [source Adobe,
see bellow]</p>
<p>But, I guess, what you want, is to create a separate project for
each module, so you can test them separately?</p>
<p>In the following linked articles you’ll see the advantages
and disadvantages of each approach:</p>
<p><a href=
"http://my.safaribooksonline.com/book/programming/flex/00120090002si/creating-modules-in-flex-builder/149">
http://my.safaribooksonline.com/book/programming/flex/00120090002si...</a></p>
<p>Adobe Flex 4.7<br>
<a href=
"http://help.adobe.com/en_US/flashbuilder/using/WSe4e4b720da9dedb5-1a92eab212e75b9d8b2-7ff2.html#WSe4e4b720da9dedb5-1a92eab212e75b9d8b2-7fec">
http://help.adobe.com/en_US/flashbuilder/using/WSe4e4b720da9dedb5-1...</a></p>
<p>Adobe Flex 4.6<br>
<a href=
"http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-799a.html">
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c...</a><br>
<a href=
"http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7d1f.html">
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c...</a></p>
<p>Maybe a better solution for your use case would be to create a
separate project for all modules, where you can load only the
module that needs testing.<br>
Of course, you can also build sub-applications for each functional
area that you need in your main app, and then load the
sub-applications as swfs, or you can use a library project. It all
depends on what you need.</p>
<p>Does this help?</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/192768842012-10-04T12:07:01Z2012-10-04T12:11:17ZRobotlegs 1.5.2 : Compiling Modules as swf's<div><p>Thanks Ondina this helps. I guess I was confused by the fact
that I'm building a pure AS3 project revamp. I like this
approach:</p>
<p>'You can also create a separate Flex or ActionScript project for
each module or for groups of modules. This gives you greater
control over how modules are compiled because each project can have
different compiler options than the application or other modules.
It also lets you compile the module’s project or projects
without compiling the application. However, this approach requires
that you manually compile each module before compiling the
application. One way to do this is to compile all open projects in
Flash Builder at one time.'</p>
<p>This seems to be a good solution to me cause it enables me to
compile each project separately to test. So I would treat each
separate project as a Robotlegs module.</p>
<p>Not sure how everything would plug together but Ill see how as I
move along.</p>
<p>Any light you can shed on how my module library should relate to
the main application code would be great. For example I could treat
my main application as code library for entire project? Rather than
dubplicating the lib .swc files....Not sure if there is any best
practice here.</p>
<p>But perhaps you have already implied an answer as the module and
vice versa application does not check against eachother Compile
time. So each project should be set to run independently and have
it's own libraries.</p>
<p>Thanks! I believe it's time for a small cup of coffe.</p></div>thomas.thorstenssontag:robotlegs.tenderapp.com,2009-10-18:Comment/192768842012-10-04T13:04:34Z2012-10-04T13:04:34ZRobotlegs 1.5.2 : Compiling Modules as swf's<div><p>Well, it’s a complex topic, and I’m afraid I
won’t be able to get into all the details :)</p>
<p>Let’s say you have a separate project where you have a
main display object and one module (SomeExternalModule), that you
want to load in another project.<br>
There, where you want to load the module (your main project), you
define the source path of the module (SomeExternalModule) under
Properties->Flex build path-> source path ( I’m using
FlashBuilder). Then you go to Properties->Flex modules and you
add something like this: [source path] src\SomeExternalModule.mxml,
which is the path to the external module, defined previously. The
main app can load this module as any other module.</p>
<p>Now, about libraries: You actually have a main project and
another, separate library project. The main project is the one
loading the classes, components, or whatever, contained in a
library, not vice versa. In a library you put things that you want
to share with other projects, or other modules. Say, you have a
library for styles, or you can have a library containing robotlegs
models and services, that you can use for a desktop, browser or
mobile app. They all share the same models and services, while the
views are different.<br>
Or you can have a library of different components that you load in
different parts of your app.</p>
<p>You’ll have to read more about optimizing modules, runtime
shared libraries …:)<br>
There are also some discussions on this forum about library
projects. If you want to see a project using a library take a look
at the links from my answer here:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/problems/638-multiple-contexts-using-the-same-context-view#comment_18728546">
http://knowledge.robotlegs.org/discussions/problems/638-multiple-co...</a></p>
<p>I’m sorry that I can’t help you more, but even if I
had more time, without a concrete use case to talk about,
it’s really a huge topic.</p>
<blockquote>
<p>Thanks! I believe it's time for a small cup of coffe.</p>
</blockquote>
<p>You’re welcome, Thomas. Oh, I think I need coffee, too ;)
No sugar, of course.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/192768842012-10-04T14:41:36Z2012-10-04T14:42:37ZRobotlegs 1.5.2 : Compiling Modules as swf's<div><p>Hi</p>
<p>Yes I used libraries swc's and Flex modules in Flashbuilder
before as Flashbuilder is my premium tool nowadays albeit I have a
past with FDT and Flashdevelop and before that Scintilla.</p>
<p>The thing is that this is Not A Flex Project. So thats why I
seem confused. I also am slightly in the dark due to that I am
using Robotlegs in a non flex pure actionscript modular
context.</p>
<p>But, based on your answers above I will be able to figure it
out. I assume something like this can be done without Flex based
modules.</p>
<p>I dig further and thanks for your time.</p>
<p>Thomas, Over half a mug of latte</p></div>thomas.thorstenssontag:robotlegs.tenderapp.com,2009-10-18:Comment/192768842012-10-04T16:45:34Z2012-10-04T16:45:34ZRobotlegs 1.5.2 : Compiling Modules as swf's<div><p>If it’s a pure as3 project, the only thing different from
what I said in the other post is :</p>
<p>[source path] src\SomeExternalModule.as</p>
<p>as. instead of .mxml</p>
<p>The component that is supposed to be loaded as a module extends
Sprite, and what matters in the end is the swf file you load via
your SWFLoader.</p>
<p>I guess you’re already aware of this: <a href=
"https://github.com/robotlegs/robotlegs-framework/wiki/Common-Problems#wiki-metadata-stripping">
https://github.com/robotlegs/robotlegs-framework/wiki/Common-Proble...</a>
Just mentioning it, in case you need it.</p>
<p>I think that you think that the things are more complicated than
they really are ;)</p>
<p>I’m sure you’ll find a solution! If not, then come
back with questions.</p>
<p>Cheers,<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/192768842012-10-04T16:50:18Z2012-10-04T16:50:18ZRobotlegs 1.5.2 : Compiling Modules as swf's<div><p>Aha that was what I didn't realise I never added an .as file as
a module (blushes).</p>
<p>I shall code tonight. This discussion can now be closed, I'm
ready to do some work.</p>
<p>Thanks</p>
<p>Thomas</p></div>thomas.thorstenssontag:robotlegs.tenderapp.com,2009-10-18:Comment/192768842012-10-04T16:56:13Z2012-10-04T16:56:13ZRobotlegs 1.5.2 : Compiling Modules as swf's<div><p>No problem. No need to feel bad, really! Good luck!</p></div>Ondina D.F.