Nested Context

Arturo's Avatar

Arturo

11 Jul, 2011 04:49 PM

Hi,

I was wondering if RobotLegs supports nested contexts, or suggestions on to how to accomplish the following.

Basically, I have a model that I wish to tie to a view (sort of presentation model). But that view can be opened more than once (MDI style). So I want that view and it's children to access only the model that belongs to it.

I tried creating a context and setting the view as the contextview, but the children can't access elements from the MainContext. Is this possible with RL?

Thanks

  1. 1 Posted by Arturo on 11 Jul, 2011 05:05 PM

    Arturo's Avatar

    The wizzard suggested an article that says that Multiple contexts are supported, but It doesn't say anything else nor shows an example.

    Am I supposed to use a Modular Context even if I'm not using Module?

    Oh... something that might matter, I'm using SignalContext. Could it be a bug in it?

  2. 2 Posted by Stray on 11 Jul, 2011 07:46 PM

    Stray's Avatar

    Hi Arturo,

    If you want to share injections between the contexts then you need Joel Hook's Modular utility:

    https://github.com/joelhooks/robotlegs-utilities-Modular

    Although this is able to handle separately-compiled swfs, it works just as well with instantiated 'modules'.

    Signals can play too.

    Stray

  3. 3 Posted by Arturo on 11 Jul, 2011 08:04 PM

    Arturo's Avatar

    Great, thank you. I thought so, but wasn't sure if that was the way to go, since the name hints towards being focused for Modules, and maybe I was just flat out missing something.

    I saw a post that shows how to build a ModularSignalContext.

    http://knowledge.robotlegs.org/discussions/questions/405-signalcont...

    I will follow that.

    Thanks.

  4. 4 Posted by visnik on 14 Jul, 2011 10:17 PM

    visnik's Avatar

    Not trying to hijack the post, but i wasn't sure if I should create new topic or just post in this one. Basically I had a question about nested swfs and RL. Can you have separate swf files with separate contexts (work just fine on their own) load one swf into another and have it work?

    I have two air apps, "A" and "B", "B" runs just fine on its own, but when I load "B" into App "A" via spark SWFLoader I get a Error 1065: , telling me an interface file I have mapped in the App 'B's" context can not be defined. Is a 3rd context needed for all nested swfs?

  5. 5 Posted by Stray on 14 Jul, 2011 10:29 PM

    Stray's Avatar

    Hi Visnik,

    how are you doing the loading? And what app domain / security domain are you using?

    Air is so paranoid about these things...

    Stray

  6. 6 Posted by visnik on 14 Jul, 2011 11:01 PM

    visnik's Avatar

    Sorry for my ignorance, but I am tot sure as far as app domain / security domain go, I have never messed with any of that. I just have two projects in a workspace, a main App project and a child app project. I am not loading anything from an external location. I have the child app publish the swf into the bin-debug directory of the main app (so i don't have to copy it later) and have the main app load it via a SWFLoader.

    I am not sure if that answers you question, sorry.

  7. 7 Posted by Stray on 14 Jul, 2011 11:07 PM

    Stray's Avatar

    Hi Visnik - that's ok, it's not ignorance, just experience you haven't got *yet* :)

    So - the way Air deals with loading swfs is very different from how a normal flash or flex application loads a swf.

    Adobe have some explanations of it - I'd do a bit of googling and read around. The summary is that you can only pass information between swfs in Air in a very restricted way.

    Stray

  8. 8 Posted by visnik on 15 Jul, 2011 12:23 AM

    visnik's Avatar

    Stray

    I will do some research on it, and get back to you.

    Thanks.

  9. 9 Posted by visnik on 15 Jul, 2011 05:48 PM

    visnik's Avatar

    Stray,
    I have been reading up on this Security/application domain stuff. From what I understand my two applications are in the same security domain (they are both on my local machine, not different servers). The child swf is actually placed into the parent/loading swfs bin-debug directory.

    From my understanding of the application domain, is so parent and child can use each other's classes directly. I am not trying to use the parents classes or child classes directly (at least I don’t think so), each class/interface should be encapsulated within each swf.
    I am using the following line of code in my main/shell application to load a child swf:

    <s:SWFLoader id="CharacterSelectionMenu" source="CharacterCreationMenu.swf"/>

    I do see in the second line of my my error that it does say at flash.system::ApplicationDomain/getDefinition()” which makes me wonder if it is a RL issue at all and I am in the wrong forum. I initially thought that it might be a context/mapping issues and my main app context was looking for the ICharacterService interface that is referenced in the child swf and it’s context. I really have no idea why I get this error, any additional guidance would be welcomed.

    Thanks, Joe

    Here is my full error: If it helps.
    `ReferenceError: Error #1065: Variable ICharacterService is not defined.

    at flash.system::ApplicationDomain/getDefinition()
    at org.swiftsuspenders.injectionpoints::PropertyInjectionPoint/initializeInjection()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/injectionpoints/PropertyInjectionPoint.as:58]
    at org.swiftsuspenders.injectionpoints::InjectionPoint()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/injectionpoints/InjectionPoint.as:19]
    at org.swiftsuspenders.injectionpoints::PropertyInjectionPoint()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/injectionpoints/PropertyInjectionPoint.as:31]
    at org.swiftsuspenders::Injector/getInjectionPoints()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/Injector.as:271]
    at org.swiftsuspenders::Injector/instantiate()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/Injector.as:130]
    at org.robotlegs.base::CommandMap/execute()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/CommandMap.as:168]
    at org.robotlegs.base::CommandMap/routeEventToCommand()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/CommandMap.as:223]
    at Function/<anonymous>()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/CommandMap.as:98]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at org.robotlegs.base::ContextBase/dispatchEvent()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/ContextBase.as:70]
    at com.projectrenascent.context::CharacterCreationContext/startup()[C:\Users\jcolumbe\Desktop\Flash Builder WorkSpaces\ProjectRenescent\CharacterCreationMenu\src\com\projectrenascent\context\CharacterCreationContext.as:64]
    at org.robotlegs.mvcs::Context/onAddedToStage()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/mvcs/Context.as:271]
    at flash.display::DisplayObjectContainer/addChildAt()
    at mx.managers::SystemManager/preloader_preloaderDoneHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\SystemManager.as:2670]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.preloaders::Preloader/displayClassCompleteHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\preloaders\Preloader.as:582]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.preloaders::SparkDownloadProgressBar/initCompleteHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\preloaders\SparkDownloadProgressBar.as:1087]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.preloaders::Preloader/dispatchAppEndEvent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\preloaders\Preloader.as:380]
    at mx.preloaders::Preloader/appCreationCompleteHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\preloaders\Preloader.as:590]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:13128]
    at mx.core::UIComponent/set initialized()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:1818]
    at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:842]
    at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]`
    

    EDIT: not sure if this helps, but the error is being thrown in my child swf's context when loaded into the parent app. If i run the child swf the error of course is not thrown.

  10. 10 Posted by Stray on 15 Jul, 2011 06:20 PM

    Stray's Avatar

    Hi Visnik,

    Loaded swfs in Air are different from loaded swfs in web - it's not possible to load a swf into the same App domain, or even the same security domain, as the shell.

    The only way to do that is with loadbytes - so the directory isn't really what matters here, only swfs in the application directory (Those installed with the shell) can access the same app / security domain as the shell afaik.

    So - whatever is happening, do be sure to test under install as well because it's all kind of different!

    But yes, it sounds like you might be banging into the Air loaded swfs issue rather than anything specific to Robotlegs.

    I have a secure-swf loader - it's on my github. It allows signed air packages to be loaded using LoadBytes.

    Not sure if it is what you need, but if so then at least you know it's possible!

    https://github.com/Stray/Air-Secure-Module-Loading

    Stray

  11. 11 Posted by visnik on 15 Jul, 2011 06:35 PM

    visnik's Avatar

    Stray,

    As I read more and more I am finding out that I can't load a child swf into an parent swf in AIR unless it is loaded from bytecode (using Loader.loadBytes), so I guess using the spark SWFLoader is not an option.

    Thanks for all your help on this, I will try testing via install and take a look at your Secure Module Loading.

    thanks again... sorry I hijacked the post on something that ened up completely un-related.

    Joe

  12. 12 Posted by Stray on 15 Jul, 2011 06:39 PM

    Stray's Avatar

    It's all AS3 dev in the end :)

    Shout if you need any help with loading modules,

    Stray

  13. Ondina D.F. closed this discussion on 01 Nov, 2011 06:24 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