What's the proper way of using Robotlegs ?

WaZz's Avatar

WaZz

05 Mar, 2010 10:28 PM

I am learning robotlegs, and so far, I have to admit that I like it. Very simple and powerfull too.

I have to say, that I am a huge fan of pureMVC framework, and I try to see what are the differences between those 2 frameworks.

My first question is what's the difference between a Context and an ApplicationFacade ? For me they look the same, and I use the Context class the same way as an ApplicationFacade, like so :

    public function MainContext(contextView:DisplayObjectContainer, local:Boolean) {
        _local = local;
        super(contextView);
    }

    override public function startup():void{
        commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, StartupCommand, ContextEvent, true);

        injector.mapSingleton(ApplicationModel);
        var appModel:ApplicationModel = injector.instantiate(ApplicationModel);
        appModel.local = _local;

        super.startup();
    }

Now my next question, is about the StartupCommand. Sometimes, I need to inject data to my models, but I think, my code would be more pretty if I build all my applications models or services within the StartupCommand. But I can't figure out a way a passing a variable to my StartupCommand. Can anyone help me on that. As you can see in my exemple above, I inject a local variable to my appModel. Is there a way of passing that variable to the StartupCommand ?

Now my last question is more about proper way of using the framework. Should I use an addChild to a command ? I had a talk with my collegue which told me, that it doesn't matter. On my side, I use the StartupCommand just to map views or create models, here is an example :

public class StartupCommand extends Command {

    private var _applicationMediator:ApplicationMediator;

    /*-----------------------------------------------------------------------------------------
    Public methods
    -------------------------------------------------------------------------------------------*/       
    override public function execute():void {
        mediatorMap.mapView(PlayButton, PlayButtonMediator);
        mediatorMap.mapView(PauseButton, PauseButtonMediator);
        mediatorMap.mapView(StopButton, StopButtonMediator);
        mediatorMap.mapView(VideoTrack, VideoTrackMediator);
        mediatorMap.mapView(SoundButton, SoundButtonMediator);
        mediatorMap.mapView(TimeCounter, TimeCounterMediator);
        mediatorMap.mapView(FullScreenButton, FullScreenButtonMediator);
        mediatorMap.mapView(Tooltip, TooltipMediator);          

        mediatorMap.mapView(StreamVideoPlayer, VideoPlayerMediator, IAbstractVideoPlayer);
        mediatorMap.mapView(YouTubeVideoPlayer, VideoPlayerMediator, IAbstractVideoPlayer);

        //Last thing to be mapped, as it will build/launch the entire application
        mediatorMap.mapView(contextView, ApplicationMediator);
    }

}

And then all my addChild goes to the ApplicationMediator.

Can you just give me your input on how you do it :)

  1. Stray closed this discussion on 10 Feb, 2011 05:02 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