Best Practice-adding views to displaylist ?

99 views
Skip to first unread message

eco_bach

unread,
Dec 11, 2010, 11:08:05 AM12/11/10
to Robotlegs AS3
Hi
Confused as to what is the 'best practice' in RL for adding view
components to the display list in RL. In John Lindquist's hello world
demo he adds them directly in the Context startup method.
In the RIA tutorial, it is recommended to add them via an Application
mediator calling a creatChildren' method in you context or main
document view.
http://insideria.com/2010/06/an-introduction-to-robotlegs-a-1.html

In PureMVC projects, what I do is utilize a Stagemediator class, then
send the views to this mediator via the view's corresponding mediator.

Stray

unread,
Dec 11, 2010, 11:19:51 AM12/11/10
to robo...@googlegroups.com
Again, there probably isn't a one-size-fits-all best practice.

If all your views are on stage from the get go, and never leave, then adding them to the stage in the context (in a small app) is an ok solution.

The bigger and more dynamic your application the more carefully you'll need to consider this.

Commands also have access to the contextView, so I tend to add the 'main' view in a BootstrapCommand.

Then subsequent dynamic views are added by the parent that they live in, triggered by an event picked up in the mediator of that view.

There are a huge number of ways you can subdivide your views & mediators because of the flexibility of the flash display list - so the 'right' level at which to mediate is going to be down to a mix of the specifics of your application and your personal coding preferences.

I like to mediate at a pretty finely grained level, having lots of simple mediators that may only dispatch or listen to one event. Others prefer to have fewer mediators and more API on their higher level views - particularly if performance is a priority.

One thing that strikes me from your question though - it's worth remembering that the mediator won't exist until after the view is actually added to the stage - so the "send the views to this mediator via the view's corresponding mediator" part doesn't sound like it would work in the conventional robotlegs framework.

You can mediate the contextView itself too - useful for totally refreshing the view, for example after a 'restart' in a 'game over' scenario.

Hope that's helpful - sorry there isn't more firm guidance on this, but robotlegs is particularly flexible in this area.

Stray

> --
> You received this message because you are subscribed to the Google
> Groups "Robotlegs" group.
> To post to this group, send email to robo...@googlegroups.com
> To unsubscribe from this group, send email to
> robotlegs+...@googlegroups.com
> for support visit http://knowledge.robotlegs.org

Reply all
Reply to author
Forward
0 new messages