Where to add to context View

dhagenbln's Avatar

dhagenbln

11 Feb, 2014 10:53 PM

Hi, I am a complete newbe with RL2 currently trying it with a pure AS3 Project and one thing I wonder about is where do I add the Views to the DisplayList? In RL1 you would extend the Context and simply call contextView.addChild but that option does not seem to be available. Any Best Practices here? By the way I am really struggling with the lack of updated examples. It's hard to be a RL2 newbe. :P

Thanks in advance

  1. Support Staff 1 Posted by Ondina D.F. on 12 Feb, 2014 09:42 AM

    Ondina D.F.'s Avatar

    Hello,

    By the way I am really struggling with the lack of updated examples. It's hard to be a RL2 newbe. :P

    Hmm, that's true, sadly. Hopefully, the discussions on this forum can compensate the lack of examples/tutorials.

    If you create your context in your 'Main' Sprite like this:

    private var _robotlegsContext:RobotlegsContext;
    private function createRLContext():void
    {
        _robotlegsContext = new RobotlegsContext(this);
    }
    

    you can use contextView.view to add children to your 'Main'

    public class RobotlegsContext
    {
        private var _context:IContext;
    
        public function RobotlegsContext(view:DisplayObjectContainer)
        {
            var contextView:ContextView = new ContextView(view);
    
            _context = new Context()
            .install(MVCSBundle)
            .configure(ModelsConfig ,ServicesConfig, ControllersConfig, MediatorsConfig)
            .configure(contextView);
    
            ///// ADD A CHILD TO THE CONTEXT VIEW:
            contextView.view.addChild(new SomeView());
        }
    }
    

    You could as well add SomeView to the contextView.view in a handler that runs after initialization:

    _contextView = new ContextView(view);
    _context = new Context()
        .afterInitializing(addChildren)
        .install(MVCSBundle)
        ...the rest
    

    But, I think it is better to let the View itself handle the adding and removing of children, if possible.

    Hope that helps.
    Ondina

  2. 2 Posted by dhagenbln on 12 Feb, 2014 09:49 AM

    dhagenbln's Avatar

    Wow thank you for the quick reply. That really helps and I guess I will excessively use this forum from now on.
    When I have gained the basic Knowledge I will try to add some simple Hello World Examples somewhere to get the Word out.

    Thank you.

  3. Support Staff 3 Posted by Ondina D.F. on 12 Feb, 2014 10:16 AM

    Ondina D.F.'s Avatar

    Glad it helped:)

    When I have gained the basic Knowledge I will try to add some simple Hello World Examples somewhere to get the Word out.

    Yes, that would be cool!!

    I don't know whether you've seen these 2 examples, which work with the latest rl2, for sure:
    https://github.com/probertson/robotlegs-examples-Simple
    https://github.com/probertson/robotlegs-examples-Simple_NoFlex

    As for the other examples listed here: http://knowledge.robotlegs.org/discussions/examples/20-links-to-rob...

    If you want to help our community, of course, only if your time permits, you could fork some of them and make them work with the latest rl2 version.

  4. Ondina D.F. closed this discussion on 11 Mar, 2014 08:47 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