Packagecom.soma.core.view
Classpublic class SomaViews
InheritanceSomaViews Inheritance Object

Author: Romuald Quantin - www.soundstep.com

Resources: http://www.soundstep.com/downloads/somacore

Actionscript version: 3.0

Copyright: Mozilla Public License 1.1 (MPL 1.1) http://www.opensource.org/licenses/mozilla1.1.php

The SomaViews class handles the views of the application (DisplayObject).

View the examples



Public Methods
 MethodDefined By
  
Create an instance of the SomaViews class.
SomaViews
  
addView(viewName:String, view:Object):Object
Registers a view to the framework.
SomaViews
  
dispose():void
Destroys all the views and properties.
SomaViews
  
getView(viewName:String):Object
Retrieves the view instance that has been registered using its name.
SomaViews
  
getViews():Dictionary
Retrieves all the view instances that have been registered to the framework.
SomaViews
  
hasView(viewName:String):Boolean
Indicates wether a view has been registered to the framework.
SomaViews
  
removeView(viewName:String):void
Removes a view from the framework and call the (optional) dispose method of this view.
SomaViews
Constructor Detail
SomaViews()Constructor
public function SomaViews()

Create an instance of the SomaViews class. Should not be directly instantiated, the framework will instantiate the class.

Method Detail
addView()method
public function addView(viewName:String, view:Object):Object

Registers a view to the framework.

Parameters

viewName:String — Name of the view.
 
view:Object — Instance of the view.

Returns
Object — The view instance.

Example
addView(MySprite.NAME, new MySprite());
dispose()method 
public function dispose():void

Destroys all the views and properties. The class will call the dispose method of each view instance.

getView()method 
public function getView(viewName:String):Object

Retrieves the view instance that has been registered using its name.

Parameters

viewName:String — Name of the view.

Returns
Object — An Object instance.

Example
var mySprite:MySprite = getView(MySprite.NAME) as MySprite;
getViews()method 
public function getViews():Dictionary

Retrieves all the view instances that have been registered to the framework.

Returns
Dictionary — A Dictionary (the key of the Dictionary is the name used for the registration).

Example
var sprites:Dictionary = getViews();
hasView()method 
public function hasView(viewName:String):Boolean

Indicates wether a view has been registered to the framework.

Parameters

viewName:String — Name of the view.

Returns
Boolean — A Boolean.

Example
hasView(MySprite.NAME);
removeView()method 
public function removeView(viewName:String):void

Removes a view from the framework and call the (optional) dispose method of this view.

Parameters

viewName:String — Name of the view.


Example
removeView(MySprite.NAME);
Examples
Add a view.
addView(MySprite.NAME, new MySprite());
     
Remove a view.
removeView(MySprite.NAME);
     
Retrieve a view.
var sprite:MySprite = getView(MySprite.NAME) as MySprite;
     
Create a shortcut to retrieve a view is a good practice (not necessary with injection enabled).
private function get mySprite():MySprite {
    return getView(MySprite.NAME) as MySprite;
}
private function doSomething():void {
    trace(mySprite);
}