Packagegs.control
Classpublic class DocumentController
InheritanceDocumentController Inheritance Document Inheritance flash.display.Sprite

The DocumentController class is a document class that contains default startup logic.

Examples are in the guttershark repository. Most of the examples in the repository use the document controller.



Protected Properties
 PropertyDefined by
  flashvars : Object
Flashvars.
DocumentController
  model : Model
A model instance.
DocumentController
  preloader : Preloader
A preloader instance.
DocumentController
Public Methods
 MethodDefined by
  
Constructor for DocumentController instances.
DocumentController
  
dispose():void
Dispose of this document controller.
DocumentController
 Inherited
get(id:String):Document
[static] Get a document instance.
Document
 Inherited
set(id:String, doc:Document):void
[static] Set a document instance.
Document
 Inherited
unset(id:String):void
[static] Unset a document instance.
Document
Protected Methods
 MethodDefined by
  
Returns an object for standalone flashvars.
DocumentController
  
Initialize flashvars.
DocumentController
  
initModel():void
Create and load a model.
DocumentController
  
initPaths():void
Initialize paths with the model.
DocumentController
  
initStage():void
Initialize the StageRef.stage property.
DocumentController
  
initStrings():void
Initialize a Strings instance on the model.
DocumentController
  
A hook you can use to tell the document controller to grab the flashvars object from the FlashvarUtils class as an "injected flashvar".
DocumentController
  
A hook you can override to catch io loading errors for the model.
DocumentController
  
onModelReady():void
When a model is ready.
DocumentController
  
A hook you can override to catch security errors for the model.
DocumentController
  
onPreloadComplete(e:Event):void
Override this to write preload complete logic.
DocumentController
  
A hook you can use to override what key is used when the DocumentController is registered with Document.set.
DocumentController
  
A hook you can use to override what key is used when the flashvars object is register with FlashvarUtils.set.
DocumentController
  
A hook you can override to register instances with their classes.
DocumentController
  
A hook you can use to override what key is used when the model is registered with Model.set.
DocumentController
  
A hook called just before the startPreload method is called.
DocumentController
  
startPreload():void
A hook to start preloading.
DocumentController
Property detail
flashvarsproperty
protected var flashvars:Object

Flashvars.

modelproperty 
protected var model:Model

A model instance.

preloaderproperty 
protected var preloader:Preloader

A preloader instance.

Constructor detail
DocumentController()constructor
public function DocumentController()

Constructor for DocumentController instances.


Example
 
   public function DocumentController()
   {
       initStage();
       initFlashvars();
       initModel();
       initPaths();
   } 
   

Method detail
dispose()method
public override function dispose():void

Dispose of this document controller.

flashvarsForStandalone()method 
protected function flashvarsForStandalone():Object

Returns an object for standalone flashvars.

Returns
Object

Example
 
   protected function flashvarsForStandalone():Object
   {
       return {};
   }
   

initFlashvars()method 
protected function initFlashvars():void

Initialize flashvars.


Example
 
   protected function initFlashvars():void
   {
       if(qs.flashvarsurl)loadFlashvars();
       else
       {
           if(injectedFlashvarsKey())flashvars=FlashvarUtils.get(injectedFlashvarsKey());
           if(!flashvars)flashvars=FlashvarUtils.getFlashvars(this,flashvarsForStandalone);
       }
   }
   

initModel()method 
protected function initModel():void

Create and load a model.


Example
 
   protected function initModel():void
   {
       model=new Model();
       if(flashvars.model)model.load(flashvars.model,onModelReady,onModelIOError,onModelSecurityError);
       else onModelReady();
   }
   

initPaths()method 
protected function initPaths():void

Initialize paths with the model.


Example
 
   protected function initPaths():void
   {
       if(model)
       {
           model.addPath("audio",(flashvars.audio)?flashvars.audio:"../audio/");
           model.addPath("bmp",(flashvars.bmp)?flashvars.bmp:"../bmp/");
           model.addPath("css",(flashvars.css)?flashvars.css:"../css/");
           model.addPath("flv",(flashvars.flv)?flashvars.flv:"../flv/");
           model.addPath("js",(flashvars.js)?flashvars.js:"../js/");
           model.addPath("swf",(flashvars.swf)?flashvars.swf:"../swf/");
           model.addPath("xml",(flashvars.xml)?flashvars.xml:"../xml/");
       }
   }
   

initStage()method 
protected function initStage():void

Initialize the StageRef.stage property.


Example
 
   protected function initStage():void
   {
       StageRef.stage=stage;
   }
   

initStrings()method 
protected function initStrings():void

Initialize a Strings instance on the model.

If an asset is available in the AssetManager called "strings" it will initialize the model.strings property for you


Example
 
   protected function initStrings():void
   {
       if(AssetManager.isAvailable("strings") && model)model.strings=new Strings(AssetManager.getXML("strings"));
   }
   

injectedFlashvarsKey()method 
protected function injectedFlashvarsKey():String

A hook you can use to tell the document controller to grab the flashvars object from the FlashvarUtils class as an "injected flashvar".

Look at the docs for initFlashvars for how the injectedFlashvarsKey is used to get custom flashvars.

Returns
String
onModelIOError()method 
protected function onModelIOError():void

A hook you can override to catch io loading errors for the model.

onModelReady()method 
protected function onModelReady():void

When a model is ready.


Example
   protected function onModelReady():void
   {
       setupComplete();
       startPreload();
   } 
   

onModelSecurityError()method 
protected function onModelSecurityError():void

A hook you can override to catch security errors for the model.

onPreloadComplete()method 
protected function onPreloadComplete(e:Event):void

Override this to write preload complete logic.

Parameters
e:Event

Example
 
   protected function onPreloadComplete(e:Event):void
   {
       model.registerFonts();
       initStrings();
       registerInstances();
   }
      

registerDocumentKey()method 
protected function registerDocumentKey():String

A hook you can use to override what key is used when the DocumentController is registered with Document.set.

The default is main

Returns
String
registerFlashvarsKey()method 
protected function registerFlashvarsKey():String

A hook you can use to override what key is used when the flashvars object is register with FlashvarUtils.set.

The default is main

Returns
String
registerInstances()method 
protected function registerInstances():void

A hook you can override to register instances with their classes.


Example
 
   protected function registerInstances():void
   {
        if(model)Model.set(registerModelKey(),model);
        if(flashvars)FlashvarUtils.set(registerFlashvarsKey(),flashvars);
        Document.set(registerDocumentKey(),this);
   }
   

registerModelKey()method 
protected function registerModelKey():String

A hook you can use to override what key is used when the model is registered with Model.set.

The default is main

Returns
String
setupComplete()method 
protected function setupComplete():void

A hook called just before the startPreload method is called.

This is called after initStage, initFlashvars, and after a model has loaded.

startPreload()method 
protected function startPreload():void

A hook to start preloading.