Packagecom.pblabs.engine.entity
Classpublic class PropertyReference
InheritancePropertyReference Inheritance Object
Implements ISerializable

A property reference stores the information necessary to lookup a property on an entity.

These are used to facilitate retrieving information from entities without requiring a specific interface to be implemented. For example, a component that handles display information would need to retrieve spatial information from a spatial component. The spatial component can store its information however it sees fit. The display component would have a PropertyReference member that would be initialized to the path of the desired property on the spatial component.

Property References follow one of three formats, component lookup, global entity lookup, or xml lookup. For component lookup the property reference should start with an @, for global entity lookup the property reference should start with a #, and for xml lookup the property reference should start with a !. Following this starting symbol comes the name of the component, entity or XML Template respectively.

View the examples

See also

IPropertyBag.doesPropertyExist()
IPropertyBag.getProperty()
IPropertyBag.setProperty()


Public Properties
 PropertyDefined By
  cachedLookup : Array
PropertyReference
  property : String
The path to the property that this references.
PropertyReference
Public Methods
 MethodDefined By
  
PropertyReference(property:String = null)
PropertyReference
  
deserialize(xml:XML):*
deserializes the object from xml.
PropertyReference
  
serialize(xml:XML):void
serializes the object to XML.
PropertyReference
  
toString():String
PropertyReference
Property Detail
cachedLookupproperty
public var cachedLookup:Array

propertyproperty 
property:String

The path to the property that this references.


Implementation
    public function get property():String
    public function set property(value:String):void
Constructor Detail
PropertyReference()Constructor
public function PropertyReference(property:String = null)



Parameters
property:String (default = null)
Method Detail
deserialize()method
public function deserialize(xml:XML):*

deserializes the object from xml. The format of the xml passed is custom, depending on the way the object was serialized with the serialize method.

Parameters

xml:XML — The xml containing the serialized definition of the class.

Returns
* — The deserialized object. Usually 'this' should be returned, but in some cases it may be useful to return something else. The Enumerable class does this to force all values to be a member of the enumeration.
serialize()method 
public function serialize(xml:XML):void

serializes the object to XML. This should not include the main tag defining the class itself.

Parameters

xml:XML — The xml object to which the serialization of this class should be added. This xml object is a single tag containing the main class definition, so only children of this class should be added to it.

toString()method 
public function toString():String

Returns
String
Examples
The following code gets the x property of the position property of the spatial component on the queried Entity:
     @spatial.position.x
     
Property references can also access arrays and dictionaries. The following property reference is equivalent to ai.targets[0].x:
     @ai.targets.0.x
     
Global entities can be accessed with the # symbol. The following code accesses the Level entity's timer component and retrieves the timeLeft property:
     #Level.timer.timeLeft
     
XML Template properties can be accessed using the ! symbol. The following code accesses the XML Template name Enemy and retrieves the health property off of the life component:
     !Enemy.life.health