Flex/Air - Sharing code between modules

Hi,
I am a former flashbuilder user that been trying out IDEA.
I really like it. But I have question regarding modules and how to share code and assets between modules.

I have a project that I would would like to export for both air mobile and web.

This is how the folder structure looks like, before setting up IDEA. (used in fb)

- main folder
     - Base (base is used by both mobile and web version)
          - scr
          - assets (images, fonts etc. not swc)
          - lib (swc)
     - Mobile (needs to use , scr, assets and swc from base)
          - scr
     - Web (needs to use , scr, assets and swc from base)
          - scr

Wich is the best way to setup a IDEA project with modules?

2 comments

Hi,welcome to IntelliJ IDEA!
Here are some tutorials for quick start: http://confluence.jetbrains.com/display/IntelliJIDEA/Flash+Development

IntelliJ IDEA doesn't allow to configure the same content root of source folder for more than one module by design.

For you there are 2 ways to setup the project in IntelliJ IDEA:

1. Configure a single Flash module in a following way:

  • [main folder] is a content root (Project Structure | Modules | [your Flash module]),
  • Base/src, Base/assets, Mobile/src and Web/src are source folders (the same dialog),
  • configure two Flash Build Configurations (BCs) for the module (subnodes of the module node in the Project Structure dialog), one with target platform: Web and another with target platform: Mobile,
  • both BCs should have required SWCs from lib folder among dependencies. (Hint: you can setup the first BC and then press 'Copy' button at the top of the dialog to clone it and only tune options that differ.)


If you decide to go this way then you will be able to choose how to highlight source files: according to Web BC configuration or according to Mobile one. Active Flash BC is selected in the status bar or using context menu.

2. Configure a multi-modular project:
     2.1. Library module:

    • [Base] is a content root
    • Base/src and Base/assets are source folders
    • the module contains one BC with output type: Library (i.e. producing SWC)
    • required SWCs from lib folder are configured as dependencies. Default linkage type is Merged, but you may change it to Included to fully include all classes from SWCs to your resulting SWC.

     2.2. Web module

    • [Web] is a content root
    • Web/src is a source folder
    • the module contains one BC with output type: Application, target platform: Web
    • this BC depends on library BC from 2.1 Library module
    • this BC may explicitly depend on 3rd party SWCs from lib folder if library BC has dependecy on these SWCs with Merged linkage type. If library BC has dependecy on these SWCs with Included linkage type then dependency becomes transitive and you do not need to configure explicit dependency of Web on 3rd party SWCs.

     2.3. Mobile module

    • [Mobile] is a content root
    • Mobile/src is a source folder
    • the module contains one BC with output type: Application, target platform: Mobile
    • this BC also depends on library BC from 2.1 Library module
    • the same about 3rd party libs as for Web module.
0

Thanks alot!
I will try it out.

0

Please sign in to leave a comment.