External SWF Module in Flex Module Loader and PopupManager

thexeb's Avatar

thexeb

17 Dec, 2012 02:15 PM

hi, I have facing difficulty with Mediating an external Module(swf) into Shell Application,
I have all external modules (swf) mapped in ShellContext as
viewMap.mapType(IModule);

My shell Module (mxml view) has two external swf loaded into ModuleLoader and are mediated correctly , Now i need a module to be a Dialog Window which is also an external module , so i declare it as non- visual element as below:

<fx:Declarations>
    <flex:ModuleProgressLoader  id="module_fileLoad" width="600" height="550" url="FileLoadModule.swf"  />                
</fx:Declarations>

So when requested, shellMediator shows this module in a Popup,

PopUpManager.addPopUp(shell.module_fileLoad,contextView,true); //shell=injected ShellView
PopUpManager.centerPopUp(shell.module_fileLoad);

but this fileload module is not mediated , there is no execution of methods startup(context) and so onRegister(Mediator) of the FileLoadModule. This module works good if i place in the visual list of main ShellModule View.
Plz tell me how to solve this problem.

  1. Support Staff 1 Posted by Ondina D.F. on 17 Dec, 2012 02:32 PM

    Ondina D.F.'s Avatar

    Hi thexeb,

    You need to create the mediator manually.

    See here:
    http://knowledge.robotlegs.org/kb/reference-mvcs-implementation/how...

    hth
    Ondina

  2. Support Staff 2 Posted by Ondina D.F. on 17 Dec, 2012 03:10 PM

    Ondina D.F.'s Avatar

    OK, I was too fast:) The context of your module is not initialized because the module is not added to the stage, but to the SystemManager.

  3. Support Staff 3 Posted by Ondina D.F. on 17 Dec, 2012 03:28 PM

    Ondina D.F.'s Avatar

    You could set the SystemManager as the contextView, in your main context, like this:

    public class ApplicationContext extends ModuleContext
    {
    public function ApplicationContext(contextView:DisplayObjectContainer = null, autoStartup:Boolean = true)
    {
        super(contextView.parent, autoStartup);//parent =>>SystemManager
     }
     override public function startup():void
    {
        viewMap.mapType(IModule);
    }
    

    And then there, where you load the module:
    PopUpManager.addPopUp(moduleLoader , FlexGlobals.topLevelApplication as DisplayObject);
    where moduleLoader is a ModuleLoader ;)

  4. 4 Posted by thexeb on 17 Dec, 2012 07:35 PM

    thexeb's Avatar

    Stil not working , I have now main context declared as

    <fx:Declarations>
            <local:ShellContext contextView="{DisplayObjectContainer(FlexGlobals.topLevelApplication)}"/>
            <flex:ModuleProgressLoader  id="module_fileLoad" width="600" height="550" url="FileLoadModule.swf"  />
    </fx:Declarations>
    

    and adding popup in ShellMediator as:

    PopUpManager.addPopUp(shell.module_fileLoad,FlexGlobals.topLevelApplication as DisplayObject,true);
                PopUpManager.centerPopUp(shell.module_fileLoad);
    

    but its still not working,, other two external modules (on Shell View Displaylist) are working fine.

  5. 5 Posted by thexeb on 18 Dec, 2012 06:11 AM

    thexeb's Avatar

    what is that i m missing , :(

  6. Support Staff 6 Posted by Ondina D.F. on 18 Dec, 2012 11:38 AM

    Ondina D.F.'s Avatar

    local:ShellContext contextView="{DisplayObjectContainer(FlexGlobals.topLevelApplication)}"

    You don’t have access to the system manager in your example.
    3 possible solutions:

    • [1] If you use the declaration tag, set the contextView like this:
    <common:ApplicationContext contextView="{SystemManager.getSWFRoot(this) as DisplayObjectContainer}"/>
    

    Or like so:

    <common:ApplicationContext contextView="{parentContainer}"/>
    

    Where parentContainer is:

    [Bindable]
    private var parentContainer:DisplayObjectContainer;
    

    and set inside the preinitialize handler:

    private function preinitializeHandler(event:FlexEvent):void
    {
         parentContainer=this.parent;
    }
    

    And in your context just as usual:
    super(contextView , true);

    • [2] I’d prefer to initialize the context in actionscript within the preinitialize handler for the FlexEvent.PREINITIALIZE, fired by the application:
    private var context:ApplicationContext;
    private function preinitializeHandler(event:FlexEvent):void
    {
         context = new ApplicationContext(this.parent);
    }
    

    and in the context:

    super(contextView, true);

    Or as in my previous post:

    private function preinitializeHandler(event:FlexEvent):void
    {
         context = new ApplicationContext(this);
    }
    

    and in the context:

    super(contextView.parent , true);

    • [3] pass the parent injector on to the module through its interface

    You initialize your context as you wish, inside the declaration tag or in actionscript

    <common:ApplicationContext contextView="{this}"/>
    

    Or

    private var context:ApplicationContext;
    private function preinitializeHandler(event:FlexEvent):void
    {
         context = new ApplicationContext(this);
    }
    

    and then there, where you create the popup, you pass the parent injector to the module. Of course the class that creates the popup should have access to the injector (set or Inject )

    //[Inject]
    public var _parentInjector:IInjector; 
    
    PopUpManager.addPopUp(moduleLoader, FlexGlobals.topLevelApplication as DisplayObject);
    PopUpManager.centerPopUp(moduleLoader);
    (moduleLoader.child as IModule).parentInjector=_parentInjector;
    

    Does this help?

  7. 7 Posted by thexeb on 18 Dec, 2012 11:50 AM

    thexeb's Avatar

    great that works , i just modified main context as

    <common:ApplicationContext contextView="{SystemManager.getSWFRoot(this) as DisplayObjectContainer}"/>
    

    and evrything else remain same , its working ,
    thanks alot odina :)

  8. Support Staff 8 Posted by Ondina D.F. on 18 Dec, 2012 12:24 PM

    Ondina D.F.'s Avatar

    That’s good news :) You’re welcome!

    Ondina

  9. Ondina D.F. closed this discussion on 18 Dec, 2012 12:24 PM.

  10. thexeb re-opened this discussion on 19 Dec, 2012 05:05 PM

  11. 9 Posted by thexeb on 19 Dec, 2012 05:05 PM

    thexeb's Avatar

    hi Odina , one thing happened ,
    I was debuging my app on a local server (wamp) with the default flex html wrapper, every thing working fine , then i uploaded to my remote server . I have wordpress install on remote server so i am using a plugin Kimili Flash Embed , for wraping swf. Now the loaded Module again not working,no mediation , with same build on local server working fine , does wrapper matters?what can be the issue?

  12. Support Staff 10 Posted by Ondina D.F. on 19 Dec, 2012 06:18 PM

    Ondina D.F.'s Avatar

    Hi thexeb,

    I have no idea what Kimili Flash Embed does. I went to their site, and there is a FAQ section: http://kimili.com/plugins/kml_flashembed#faqs Maybe you can find an answer there :)

    Could it be that you’re not having access to the IModule interface anymore because of that wrapper? Is the wrapper necessary? Can you at least try running the app on the server without the wrapper, to see what happens then?

    The ApplicationDomain can’t be the problem, since we’ve already discussed that in another thread, right?

    Ondina

  13. 11 Posted by thexeb on 19 Dec, 2012 06:33 PM

    thexeb's Avatar

    i have wordpress installled on my site ,this plugin suits well with it, i have already running app built with RL Modular .
    http://thexaib.com/cat_mini_apps/photo-spark-studio/

    this was pure AS3.0 app ,with two external modules,
    i am currently upgrading GUI of it, ie building in FLEX,
    the same wrapper should work ? but its not working, i don't know its about wrapper or something else. i have tried to open swf in my browser (without the wrapper) , still not working.
    http://thexaib.com/apps/xps/ShellModule.swf
    when Open File Button is clicked , an other external module is loaded.,but its not working, not mediated ,otherwise the close button would work.

  14. 12 Posted by thexeb on 19 Dec, 2012 06:38 PM

    thexeb's Avatar

    Kimili Flash Embed provide swfObject like wrapper in wordpress, its simple i think :( as my pure AS3.0 is working fine with it

  15. Support Staff 13 Posted by Ondina D.F. on 19 Dec, 2012 06:40 PM

    Ondina D.F.'s Avatar

    I’m sorry, but we’ll have to continue our discussion tomorrow. I’m about to go out for dinner.

  16. 14 Posted by thexeb on 19 Dec, 2012 06:44 PM

    thexeb's Avatar

    no problem ,thanks for your time , :)

  17. 15 Posted by thexeb on 20 Dec, 2012 06:48 AM

    thexeb's Avatar

    Now i uploaded Debug files,(Not Release Build) and its working, weird

  18. Support Staff 16 Posted by Ondina D.F. on 20 Dec, 2012 07:53 AM

    Ondina D.F.'s Avatar

    Good morning :)

    Now i uploaded Debug files,(Not Release Build) and its working, weird

    It sounds like the metadata has been stripped out. Take a look at this:

    https://github.com/robotlegs/robotlegs-framework/wiki/Common-Proble...

    If you’re using FlashBuilder, add these compiler arguments:

    -keep-as3-metadata+=Inject

    -keep-as3-metadata+=PostConstruct

  19. Support Staff 17 Posted by Ondina D.F. on 20 Dec, 2012 08:42 AM

    Ondina D.F.'s Avatar

    In the title of this discussion you mentioned that the module was external. Does that mean you compiled it in another application and then added it to the current application?
    If the answer is yes, then, if you’re using FlashBuilder, add the compiler arguments (keep metadata…) mentioned previously to the application that is creating the module, and when you create the module, choose “do not optimize (module can be loaded by multiple applications)” under Properties-Flex Modules

    In the application loading the external module choose library linkage: “runtime shared library (RSL), under Properties-Flex Build Path and also add the compiler arguments for metadata.

    Try it out and tell me how it goes.

  20. 18 Posted by thexeb on 20 Dec, 2012 10:13 AM

    thexeb's Avatar

    No same FlashBuilder is compiling multiple modules,it worked when i choose Donot Optimize . :)
    thanks Odina , u being very helpfull and kind

  21. thexeb closed this discussion on 20 Dec, 2012 10:13 AM.

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