The Gaia Flow

From Gaia Framework Wiki

Jump to: navigation, search

Contents

Introduction

Gaia has a sequence of actions that occur when the goto(branch) event fires which I refer to as The Gaia Flow. The FlowManager class is located in com.gaiaframework.flow.FlowManager. There are five steps in the Gaia Flow, and you can hijack the framework each step of the way.

  • goto: The start of every flow begins with this event.
  • transitionOut: Transitions out all current pages that do not belong to the new branch.
  • preload: Loads all the files needed for the new branch.
  • transitionIn: Transitions in the pages of the new branch. Obviously, preload must complete before this can occur.
  • complete: Occurs once the flow is complete.


Gaia Flow Types

Gaia has four different flows. They are called normal, preload, reverse and cross. You can control which of these flows you want Gaia to use both in the site.xml and at runtime. Gaia can use any combination of these flows for any page in your site.

Normal Flow

The normal flow transitions the current branch out, loads the new branch and transitions it in. This is the default behavior of the Gaia framework and works well for many sites. You can override the default flow for the site which is covered in the Site XML documentation.

  1. transitionOut
  2. preload
  3. transitionIn
  4. complete

Preload Flow

The preload flow loads the new branch before starting the transition out. You can use this flow if you want to have an uninterrupted smooth transition out and in to the new branch.

  1. preload
  2. transitionOut
  3. transitionIn
  4. complete

Reverse Flow

The reverse flow preloads the new branch and calls transition in before transition out. This is a more advanced flow and, with proper planning, you can do some really cool transitions with it. One use for this flow is if you want the new branch MovieClips to cover up the previous branch MovieClips before they transition out. Masking, reveal, and wipe transitions are also good candidates for the reverse flow.

  1. preload
  2. transitionIn
  3. transitionOut
  4. complete

Cross Flow

The cross flow preloads the new branch and calls transitionOut and transitionIn at the same time. Pages will transition out and in in the same order, the transitions just occur simultaneously. Event Hijackers that listen before transition out and in will fire back to back in that order (out then in). If one of the branches takes more time to finish its transition than the other (if one has more pages or just takes more time), whichever finishes first will fire its after event first, e.g. If the out transition finishes before the in transition does, the afterTransitionOut will fire before the afterTransitionIn.

  1. preload
  2. transitionOut and transitionIn
  3. complete


Transitions

Transitions are how pages appear or are removed from the screen. Transition Out transitions pages out one at a time from the end of the changing part of the branch to the root. As each page on the branch finishes its transition, its parent will begin transitioning out until all the pages on the branch are out. Transition In works in the opposite direction, transitioning pages in from the root of the branch to the end after that branch has loaded.

If a goto event occurs at any point during the Gaia Flow, Gaia will interrupt any running transitions or preloading.

If Gaia is in the middle a transition, it will let the currently transitioning page (in or out) finish and then start the process over again from goto.

If Gaia is in the middle of preloading, in AS3 it will abort the load immediately and in AS2 it will finish loading the current file that is loading (limitation of Flash prior to AS3). It will then start the process over again from goto.



Page Flow

Page nodes have an optional attribute flow. If you leave it out, Gaia will use the default flow for the site (which is "normal" unless otherwise set in the site node). You can override this behavior by setting it to "normal", "preload", "reverse" or "cross".

Gaia will always use the flow of the root page of the changing part of the branch. This allows you to have custom flows at different tiers in your branches.

For instance, if you are going from "index/nav/photos/family" to "index/nav/photos/friends" and the page "friends" has flow="preload", it will preload the "friends" page, then transition out "family" and then transition in "friends".

If you are going from "index/nav/photos/family" to "index/nav/videos/july2007" and the page "videos" has flow="normal", because "videos" is the root branch change from "photos", it will use the normal flow, and transition out "family", then "photos", then preload "videos" and "july2007" and transition them in.

At runtime, you can change a page's flow directly by setting its flow to any of the three flows. Use the Flow Constants when setting these at runtime. Check out the getPage() method in the API section for more information on how to target a page directly.

You can also set the global site flow at runtime, as well. Check out the setDefaultFlow() method in the API section for more information.