Loading one Robotlegs project to another Robotlegs project

Lukas's Avatar

Lukas

20 Mar, 2012 11:58 AM

Hi everyone!

I have a little problem. ( At the begining sorry if my English is bad , it's not my native language).
So i made application in RL , and now i have to include that application into another ( which is also made in RL ) .
But include have to be done by loading that smallest one app ( .swf ) into that bigger one, with preserving communication
between both of them ( both are using Events for communicating ). So I can send to small application events from that bigger one.
Important thing is - that i have still possibility to change source code from small application too.
My problem is - that I can't achieve that. I was reading lot of exaples for Modular Utility , but it's mainly for modular applications without loading standalone modules. So i can't find proper solution. Could you help me ? Maybe someone have some exemple ? I would be very gratefull for some help. Thanks !

  1. Support Staff 1 Posted by Ondina D.F. on 20 Mar, 2012 03:34 PM

    Ondina D.F.'s Avatar

    Hi Lukas,

    So i made application in RL , and now i have to include that application into another ( which is also made in RL ) .

    This looks like a sub-application to me rather than a module.
    A couple of questions to you:
    Have you tried to communicate between 2 non-rl applications already? Does this work? How are you loading the sub-application, are you using the Loader class?

    If it is a sub-application, then one possible cause of your problem could be the way you set your ApplicationDomain for the loaded swf.

    See this post for more info on ApplicationDomain: http://livedocs.adobe.com/flex/3/html/help.html?content=18_Client_S...
    Loading and managing sub-applications can be pretty annoying sometimes.

    The following code works for a sub-application:
    protected function onLoaderComplete(event:Event):void
    {

    var appDomain:ApplicationDomain=ApplicationDomain.currentDomain;
    var context:LoaderContext=new LoaderContext(false, appDomain);
    var loader:Loader=new Loader();
    loader.loadBytes(urlLoader.data, context);
    container.addChild(loader);

    sharedEventDispatcher=loader.contentLoaderInfo.sharedEvents;
    sharedEventDispatcher.addEventListener("SubAppToMainAppEvent", onSubAppChanged, false, 0, true);

    }

    protected function sendDataToSubApp():void
    {

    var dynamicEvent:DynamicEvent=new DynamicEvent("MainAppToSubAppEvent");
    dynamicEvent.data="application to subapplication";
    sharedEventDispatcher.dispatchEvent(dynamicEvent);

    }

    If this doesn’t answer your question, could you please show us the code where you are loading your second application?

    Cheers,
    Ondina

  2. 2 Posted by Lukas on 22 Mar, 2012 11:12 AM

    Lukas's Avatar

    Unfortunatelly it doesn't work like that .. There is no error during compilation. But when application fires - smallest application content doesn't appear at the stage.

    this is a code :

    protected const WALL_PATH:String = "data/small_rl_app.swf";

        public function load():void
        {   
            var loader_context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
    
            _loader = new BulkLoader("smallAppLoader");
            _loader.addEventListener(BulkProgressEvent.COMPLETE, loadSuccess);
            _loader.add(WALL_PATH, { id:WALL_PATH, context:loader_context}); 
            _loader.start();
        }
    
        protected function loadSuccess(e:BulkProgressEvent):void
        {       
            var wall:Sprite = _loader.getSprite(WALL_PATH);
                        addChild(wall);
        }
    
  3. Support Staff 3 Posted by Ondina D.F. on 22 Mar, 2012 11:47 AM

    Ondina D.F.'s Avatar

    The code snippet from my previous message works fine on my end, with 2 robotlegs applications, where one is loading the other one as a sub-application.

    So, I don’t think that your issue has anything to do with robotlegs.

    You didn’t answer my question from my previous post: Have you tried to load a sub-application in another application, where both applications are not using robotlegs or any other libraries or frameworks? Just 2 simple applications?

  4. Support Staff 4 Posted by Ondina D.F. on 22 Mar, 2012 01:14 PM

    Ondina D.F.'s Avatar

    But when application fires - smallest application content doesn't appear at the stage.

    Could it be that you created your SWFLoader or Loader through actionscript like this:

    private var swfLoader:SWFLoader;

    Then, somewhere in your code:

    var appDomain:ApplicationDomain=ApplicationDomain.currentDomain; swfLoader=new SWFLoader(); swfLoader.addEventListener(Event.INIT, swfLoaded); swfLoader.loaderContext=new LoaderContext(false, appDomain); swfLoader.load(urlLoader.data);

    and you forgot to add it to the display list?

    addElement(swfLoader);

  5. Ondina D.F. closed this discussion on 30 Mar, 2012 09:00 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