Quantcast
Channel: Simtechmedia's Flash Blog » Code
Viewing all articles
Browse latest Browse all 10

Gaia and Robotlegs together

$
0
0

Gaia and Robotlegs together

I have been doing a fair bit of adventuring in unchartered territory these last couple of months and the main things I have learnt is the concept of using programming frameworks.  I was recommended this combination by a wise person at the beginning of a project a project a few months ago .

About Gaia

Gaia is a fantastic front end framework made by Steven Sacks and has been around quiet some time.  It takes care of all the monotonous things at the start of the project and manages your assets. You simply write a XML for the basic layout of your site, and GAIA Does this for you;

  • Creates a new FlashDevelop Project
  • Creates all FLA (Index,Main,Nav,Preloader etc)
  • A FLA for each page with document Class
  • Some placeholder Page Animations
  • SWFAddress for Routing/Deeplinking
  • Placeholder navigation
  • SEO (yes it works)
  • Asset managment

All in one click, it’s a fantastic tool that I’d recommend, it does however has it’s limitation and uses so it’s not for every project.

After the initial Gaia scaffolding of the, you access Gaia using it’s very well documented API to handle global navigation and the state off the site (e.g. which page you are on ), after that though, you are on your own (which is great!) , Gaia keeps out of your way so you can do whatever you like, it  tries to be non-obstructive and doesn’t tie you down like some other front end frames works I’ve tried to use.

About Robotlegs

I wrote a blog entry on Robotlegs a few weeks ago, I’ve learnt a large amount since then but it’s still relevant to now. I’ll take a quote from there

“Robotlegs is a Framework based upon the MVC (Model View Controller) design pattern, MVC is a universal software architecture pattern that is used within many object oriented programming languages.  The Model is your program state, keeping your program variables and overall keeping the data for your program state. The View is everything that the user users, anything from a Movieclip, to a button to a sound.  And the controller is the medium that connects the view to the model.  There’s a ton of information about the MVC model if you want to know more about it.  What Robotlegs tries to do is help you program your application together, there’s no strict hard rules but more so a blueprint to get you started.”

Full article here

http://www.simtechmedia.com/blog/2010/07/my-experience-so-far-with-robotlegs/

Why use them together?

If you have two fantastic AS3 frameworks than why use them both at the same time?  Do some of their roles double up on each other? I would say yes, but there is definitely solid roles both can play in making a application where both can work in harmony, there is definitely grey area between the two frameworks and how you develop is up the actual developer (at it should be!)

Using both frameworks you can separates all front end visual tasks from your application. In a common scenario a Flash Designer will create all the pages/sections/assets of the website, Gaia itself has no knowledge of what Robotlegs is or is doing , as far as Gaia is concerned, it’s a self contained part of your flash website and is dispatching user interface events, this is pretty typical of what a VIEW does in a MCV type application.

How to use them together

So how do you use both of these technologies together? I won’t go into detail on how to use Robotlegs as there’s many resources out there to do that. Here is my approach on getting things wired together.

The typical setup is have your Context in Main, that way any Robotlegs and Gaia have a direct path to each other.

The next step is to have public functions in your Gaia pages that you would want Robotlegs to have access too, then create a Interface for your Gaia pages to make those functions visible.

Next step adding the Mediator in your Context

mediatorMap.mapView("com.roboGaia.pages.GaiaPage", GaiaPageMediator, IGaiaPage);

Notice I am not importing the Gaia Page class into my Context but a reference to it, this is so Robotlegs is not importing the whole class, just a reference to it. First variable is your Class path to your view, then your mediator , then your interface. Here is how it’s all communication is made between Gaia and Robotlegs.

What’s in the mediator and what’s in the View in this setup?

This is a infamous question that has popped up several times in my travels; where should the listeners for the UI sit, one option is this, the View listeners for its own UI, and sends UIEvent through the interface like so;

Another option is to have the UI listeners in the mediators and have the view be objects with no listeners as such;

I am a fan of the first approach as you don’t need anything to be on the mediators and it makes the mediators a bit lighter, there’s arguments for both approaches but it’s up for personal interpretation.

In Ending…

I hope you have found this entry interesting, this last couple of weeks on this project has taught me quite a bit and I hope someone out there finds some use it in. Feel free to contact me about anything I wrote about in email or twtter


Viewing all articles
Browse latest Browse all 10

Trending Articles