O'Reilly logo

ActionScript Developer's Guide to Robotlegs by Joel Hooks, Stray

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. The Robotlegs context in action

Every Robotlegs project begins with a context. Until the context is instantiated, Robotlegs isn’t up and running. To get your Robotlegs application going, you have to do two things: provide the context with a contextView and ask it to run startup.

Provide the context with a root-view

Every Robotlegs application requires a root-view—an instance of DisplayObjectContainer—which is the view that will be provided to the mediatorMap, so that when child views are added to this root-view they can be automatically mediated (an instance of their mediator is created and provided with the child view that it mediates for).

Tip

If your application is non-visual then just provide any-old placeholder instance of Sprite or DisplayObjectContainer.

Example 5-1. MosaicTool: mosaicTool.as In AS3/Flash, you’ll provide this view as the first parameter of the constructor
public class mosaictool extends Sprite
{

     protected var _context:MosaicContext;

     public function mosaictool()
     {
         _context = new MosaicContext(this);
     }
  ...
Example 5-2. KanbanApp: PersonalKanban.mxml In Flex the context can be initialized with an MXML tag; not having access to the constructor, you’ll provide this view using the contextView property
<WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns="library://ns.adobe.com/flex/spark" xmlns:kanban="robotlegs.examples.kanban.*" xmlns:view="robotlegs.examples.kanban.view.*" showStatusBar="false"> <fx:Style source="css/style.css"/> <fx:Declarations> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required