Packagecitrus.view
Classpublic class ACitrusView
InheritanceACitrusView Inheritance Object
Subclasses Away3DView, BlittingView, SpriteView, StarlingView

This is an abstract class that is extended by any view managers, such as the SpriteView. It provides default properties and functionality that all game views need, such as camera controls, parallaxing, and graphics object displaying and management.

This is the class by which you will grab a reference to the graphical representations of your Citrus Objects, which will be useful if you need to add mouse event handlers to them, or add graphics effects and filter.

The CitrusView was meant to be extended to support multiple rendering methods, such as blitting, or even Stage3D thanks to Starling and Away3D. The goal is to provide as much decoupling as possible of the data/logic from the view.



Public Properties
 PropertyDefined By
  camera : ACitrusCamera
ACitrusView
  loadManager : LoadManager
This is the manager object that keeps track of the asynchronous load progress of all graphics objects that are loading.
ACitrusView
Protected Properties
 PropertyDefined By
  _root : *
ACitrusView
  _viewInterface : Class
ACitrusView
  _viewObjects : Dictionary
ACitrusView
Public Methods
 MethodDefined By
  
ACitrusView(root:*, viewInterface:Class)
There is one CitrusView per state, so when a new state is initialized, it creates the view instance.
ACitrusView
  
addArt(citrusObject:Object):void
The active state automatically calls this method whenever a new CitrusObject is added to it.
ACitrusView
  
destroy():void
ACitrusView
  
getArt(citrusObject:Object):Object
Gets the graphical representation of a CitrusObject that is being managed by the active state's view.
ACitrusView
  
getObjectFromArt(art:Object):Object
Gets a reference to the CitrusObject associated with the provided art object.
ACitrusView
  
removeArt(citrusObject:Object):void
This is called by the active state whenever a CitrusObject is removed from the state, effectively also removing the art representation.
ACitrusView
  
update(timeDelta:Number):void
This should be implemented by a CitrusView subclass.
ACitrusView
Protected Methods
 MethodDefined By
  
createArt(citrusObject:Object):Object
A CitrusView subclass will extend this method to provide specifics on how to create the graphical representation of a CitrusObject.
ACitrusView
  
destroyArt(citrusObject:Object):void
A CitrusView subclass will extend this method to destroy the art associated with the provided CitrusObject.
ACitrusView
  
updateArt(citrusObject:Object, art:Object):void
A CitrusView subclass will extend this method to update the graphical representation for each CitrusObject.
ACitrusView
Property Detail
_rootproperty
protected var _root:*

_viewInterfaceproperty 
protected var _viewInterface:Class

_viewObjectsproperty 
protected var _viewObjects:Dictionary

cameraproperty 
public var camera:ACitrusCamera

loadManagerproperty 
public var loadManager:LoadManager

This is the manager object that keeps track of the asynchronous load progress of all graphics objects that are loading. You will want to use the load manager's bytesLoaded and bytesTotal properties to monitor when your state's graphics are completely loaded and ready for revealing.

Normally, you will want to hide your state from the player's view until the load manager dispatches its onComplete event, notifying you that all graphics have been loaded. This is the object that you will want to reference in your loading screens.

Constructor Detail
ACitrusView()Constructor
public function ACitrusView(root:*, viewInterface:Class)

There is one CitrusView per state, so when a new state is initialized, it creates the view instance. You can override which type of CitrusView you would like to create via the State.createView() protected method. Thanks to the State class, you have access to traditional flash display list, blitting and Away3D. If you want to target Starling you have to use the StarlingState class.

Parameters
root:*
 
viewInterface:Class
Method Detail
addArt()method
public function addArt(citrusObject:Object):void

The active state automatically calls this method whenever a new CitrusObject is added to it. It uses the CitrusObject to create the appropriate graphical representation. It also tells the LoadManager to begin listening to Loader events on the graphics object.

Parameters

citrusObject:Object

createArt()method 
protected function createArt(citrusObject:Object):Object

A CitrusView subclass will extend this method to provide specifics on how to create the graphical representation of a CitrusObject.

Parameters

citrusObject:Object — The object for which to create the art.

Returns
Object — The art object.
destroy()method 
public function destroy():void

destroyArt()method 
protected function destroyArt(citrusObject:Object):void

A CitrusView subclass will extend this method to destroy the art associated with the provided CitrusObject.

Parameters

citrusObject:Object

getArt()method 
public function getArt(citrusObject:Object):Object

Gets the graphical representation of a CitrusObject that is being managed by the active state's view. This is the method that you will want to call to get the art for a CitrusObject.

For instance, if you want to perform an action when the user clicks an object, you will want to call this method to get the MovieClip that is associated with the CitrusObject that you are listening for a click upon.

Parameters

citrusObject:Object

Returns
Object
getObjectFromArt()method 
public function getObjectFromArt(art:Object):Object

Gets a reference to the CitrusObject associated with the provided art object. This is useful for instances such as when you need to get the CitrusObject for a graphic that got clicked on or otherwise interacted with.

Parameters

art:Object — The graphical object that represents the CitrusObject you want.

Returns
Object — The CitrusObject associated with the provided art object.
removeArt()method 
public function removeArt(citrusObject:Object):void

This is called by the active state whenever a CitrusObject is removed from the state, effectively also removing the art representation.

Parameters

citrusObject:Object

update()method 
public function update(timeDelta:Number):void

This should be implemented by a CitrusView subclass. The update method's job is to iterate through all the CitrusObjects, and update their graphical counterparts on every frame. See the SpriteView's implementation of the update() method for specifics.

Parameters

timeDelta:Number

updateArt()method 
protected function updateArt(citrusObject:Object, art:Object):void

A CitrusView subclass will extend this method to update the graphical representation for each CitrusObject.

Parameters

citrusObject:Object — A CitrusObject whose graphical counterpart needs to be updated.
 
art:Object — The graphics object that will be updated based on the provided CitrusObject.