Robotlegs 1.5.2 : Compiling Modules as swf's

thomas.thorstensson's Avatar

thomas.thorstensson

03 Oct, 2012 09:12 PM

Hello Again!

This might seem a bit of a stupid question but:

Albeit I after some research understand how to hook up Modules with a ModuleManager : how do I compile an swf for an individual module? Cause assuming I don't compile entire application runtime, is there a good method for setting an individual modules context to compile to an swf? (It's all about view's so each module would end up being an swf in what I have in mind)

Because in a non modular RL project I create the Context from the Application Class. But assuming I just want to compile that particular individual module into an swf then that specific ModularContext needs to be added to stage.

Should I create a temporary View class and go about it that way for each module that I want to compile to swf or am I missing something obvious?

Many Thanks
Thomas

  1. Support Staff 1 Posted by Ondina D.F. on 04 Oct, 2012 11:51 AM

    Ondina D.F.'s Avatar

    Hi Thomas!

    “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]

    Compile a single module’s project

    1. Right-click the module’s MXML file in the module’s project.
    2. 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.

    Recompiling modules

    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.
    If the module is in a separate project than the application that loads it, you must recompile the module separately. [source Adobe, see bellow]

    But, I guess, what you want, is to create a separate project for each module, so you can test them separately?

    In the following linked articles you’ll see the advantages and disadvantages of each approach:

    http://my.safaribooksonline.com/book/programming/flex/00120090002si...

    Adobe Flex 4.7
    http://help.adobe.com/en_US/flashbuilder/using/WSe4e4b720da9dedb5-1...

    Adobe Flex 4.6
    http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c...
    http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c...

    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.
    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.

    Does this help?

    Ondina

  2. 2 Posted by thomas.thorsten... on 04 Oct, 2012 12:07 PM

    thomas.thorstensson's Avatar

    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:

    '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.'

    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.

    Not sure how everything would plug together but Ill see how as I move along.

    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.

    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.

    Thanks! I believe it's time for a small cup of coffe.

  3. Support Staff 3 Posted by Ondina D.F. on 04 Oct, 2012 01:04 PM

    Ondina D.F.'s Avatar

    Well, it’s a complex topic, and I’m afraid I won’t be able to get into all the details :)

    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.
    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.

    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.
    Or you can have a library of different components that you load in different parts of your app.

    You’ll have to read more about optimizing modules, runtime shared libraries …:)
    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:
    http://knowledge.robotlegs.org/discussions/problems/638-multiple-co...

    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.

    Thanks! I believe it's time for a small cup of coffe.

    You’re welcome, Thomas. Oh, I think I need coffee, too ;) No sugar, of course.

    Ondina

  4. 4 Posted by thomas.thorsten... on 04 Oct, 2012 02:41 PM

    thomas.thorstensson's Avatar

    Hi

    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.

    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.

    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.

    I dig further and thanks for your time.

    Thomas, Over half a mug of latte

  5. Support Staff 5 Posted by Ondina D.F. on 04 Oct, 2012 04:45 PM

    Ondina D.F.'s Avatar

    If it’s a pure as3 project, the only thing different from what I said in the other post is :

    [source path] src\SomeExternalModule.as

    as. instead of .mxml

    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.

    I guess you’re already aware of this: https://github.com/robotlegs/robotlegs-framework/wiki/Common-Proble... Just mentioning it, in case you need it.

    I think that you think that the things are more complicated than they really are ;)

    I’m sure you’ll find a solution! If not, then come back with questions.

    Cheers,
    Ondina

  6. 6 Posted by thomas.thorsten... on 04 Oct, 2012 04:50 PM

    thomas.thorstensson's Avatar

    Aha that was what I didn't realise I never added an .as file as a module (blushes).

    I shall code tonight. This discussion can now be closed, I'm ready to do some work.

    Thanks

    Thomas

  7. Support Staff 7 Posted by Ondina D.F. on 04 Oct, 2012 04:56 PM

    Ondina D.F.'s Avatar

    No problem. No need to feel bad, really! Good luck!

  8. Ondina D.F. closed this discussion on 04 Oct, 2012 04:56 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac