Robotlegs 1 and Modules

mbarjawi's Avatar


30 Jul, 2012 11:34 PM

I came across a strange problem regarding Modules.

I am trying to create a modular robotlegs application. Flash Builder is annoyed (gives warning) by referencing the Module directly inside the application. It says that its better to create an interface and then reference that. I totally agree with it as referencing the Module directly inside our application defies the logic behind having modules in the first place: to load/unload specific parts of the application at will.

Now, the only way I can find for using the modular robotlegs is to reference the module directly, because I will have to use:

viewMap.mapType( MyModuleType );

Which also makes it silly to use the ModuleLoader to load the module, because the module is already directly compiled into the software... AND it actually doesn't work and results in strange errors inside adobe's framework where I cannot reach.

And if I don't use ModuleLoader, then again, I am referencing the module itself as in:

<MyModuleType width="100%" height="100%"/>

was wondering if anybody came across a solution for this problem.
Thanks for your support,

  1. 1 Posted by Stray on 31 Jul, 2012 09:23 AM

    Stray's Avatar

    Hi there,

    implement a method in your own custom module interface which returns the concrete type:

    public function getViewMappingType():Class

    and then do the view mapping programmatically.



  2. 2 Posted by mbarjawi on 31 Jul, 2012 07:19 PM

    mbarjawi's Avatar

    Thank you Stray for your help.

    So I created an interface like this:

    public interface IMyModule extends IEventDispatcher
        function getViewMappingType():Class;

    Then modified my Module by using the implements tag like this:

    <s:Module .......

    Then implemented the interface method inside the script tag of the Module, like this:

                public function getViewMappingType():Class
                     return MyModule;

    Now, inside my application's context, I created a new public function

    public function mapMyModule():void
        viewMap.mapType( IModule(contextView.moduleLoader.child).getViewMappingType() );

    And inside my main application, I listened for the ready event for the ModuleLoader. Inside the handler, I called the mainContext.mapSkillPlanModule(); method.

    Things work, and I can trace inside the code and can get to the module's context...etc. However a new strange bug was introduced,,, inside my Module, I simply have one view MyModuleView. I am getting the following error:

    ReferenceError: Error <a href="/discussions/problems/1065" title="Discussion #1065">#1065</a>: Variable MyModuleView is not defined.
        at flash.system::ApplicationDomain/getDefinition()
        at org.swiftsuspenders.injectionpoints::PropertyInjectionPoint/applyInjection()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/injectionpoints/]
        at org.swiftsuspenders::Injector/injectInto()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/]
        at org.swiftsuspenders::Injector/instantiate()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/]
        at org.robotlegs.base::MediatorMap/createMediatorUsing()[D:\BarjawiFiles\Workplace\FlashBuilderProjects\robotlegs-framework-v1.5.2\src\org\robotlegs\base\]
        at org.robotlegs.base::MediatorMap/onViewAdded()[D:\BarjawiFiles\Workplace\FlashBuilderProjects\robotlegs-framework-v1.5.2\src\org\robotlegs\base\]
        at flash.display::DisplayObjectContainer/addChildAt()
        at mx.core::UIComponent/$addChildAt()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\]
        at mx.core::UIComponent/addChildAt()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\]
        at spark.components::Group/addDisplayObjectToDisplayList()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\]
        at spark.components::Group/[E:\dev\4.y\frameworks\projects\spark\src\spark\components\]
        at spark.components::Group/setMXMLContent()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\]
        at spark.components::Group/set mxmlContent()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\]

    So I am not sure what this bug is all about... since everything works fine when not using ModuleLoader and just referencing the Module directly.

    But since the bug happens somewhere near swiftsuspenders and robotlegs, I thought you might have an idea.

    One last note, once I click "continue" on the "error" box, the MyModuleView does load but nothing in it works (which means the mediator didn't run and the handlers are not set).

    I tried removing the

    mediatorMap.mapView( MyModuleView, MyModuleViewMediator );

    from the module context, compile, and run... I don't get the error anymore, but still nothing works in the view as the Mediator didn't run.

    Thanks again for you time and help,

  3. Support Staff 3 Posted by Ondina D.F. on 01 Aug, 2012 12:22 PM

    Ondina D.F.'s Avatar


    Regarding the error:
    The error message you’ve got says something about ApplicationDomain.
    Could it be that you forgot to define it?

    <s:ModuleLoader id="moduleLoader" applicationDomain="{ApplicationDomain.currentDomain}"

    I’ve just tried an rl1 modular app, and I get the same errors when I omit setting the applicationDomain.

  4. 4 Posted by mbarjawi on 01 Aug, 2012 05:57 PM

    mbarjawi's Avatar

    Thank you so much Ondina for your response.

    Yes you were correct. I actually never used the applicationDomain property whenever loading modules... I wasn't aware of it.

    It seems that it is a must to use the applicationDomain property when using reflection which I think is being utilized in robotlegs.

    Thanks for both of you for all your help.

  5. mbarjawi closed this discussion on 01 Aug, 2012 05:58 PM.

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

Keyboard shortcuts


? 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