class com.senocular.xml
var definition:XML =
<display:Sprite x="50" y="100"
xmlns:display="flash.display"
xmlns:def="com.senocular.xml.XMLDefinition">
<display:Shape />
<def:property def:name="graphics">
<def:call def:name="lineStyle">
<def:arguments>
<Number>1</Number>
<uint>0xFF0000</uint>
</def:arguments>
</def:call>
<def:call name="lineTo">
<def:arguments>
<Number>100</Number>
<Number>100</Number>
</def:arguments>
</def:call>
</def:property>
</display:Sprite>;
var sprite:Sprite = XMLDefinition.parse(definition);
| Properties | |
|---|---|
| namespace | The namespace used to indicate special nodes (property, call, arguments, name) in the XML definition. Its prefix is "def" and its uri is "com.senocular.xml.XMLDefinition". |
| Methods | |
|---|---|
| create() | Creates a definition XML from a target object. To limit the
number of properties that can be returned with the resulting
XML, an array of XMLDefinitionFilter instances can be used to
determine, by type, which properties are included. The resulting
XML object can be used with XMLDefinition.parse to recreate
the original object.
Namespaces for the XML returned are automatically named using an incrementing numeric suffix following "ns" for all namespaces except the definition namespace (used for definitions specific to the XMLDefinition class) which instead uses the prefix "def". |
| parse() | Creates an object (typically a display object) based on the definition
outlined by the XML. Each XML element represents the object to be
made. If that object's definition is in a pacakge, that element
will need to be in a namespace whose uri matches that package. The
hierarchy of the object created will match the hierarchy of the XML
where display objects will be added as children to the display objects.
Attributes are used to define properties. If a name attribute is
defined, that name will also be used as a property name in the parent
to store a reference to the child. If the parent is not a display
object container or the child is not a display object and a name
attribute is not provided, the child element's index will be used;
this is useful when defining arrays as name attributes are not needed.
Errors (most if not all) will fail silently. |
public static function get namespace():Namespace
public static function create(target:Object, xmlParent:XML = null, filters:Array = null, name:String = "", isProperty:Boolean = false):XML
target | The target object from which a definition XML object is generated. |
xmlParent | The XML node in which the resulting XML is inserted. |
filters | An array of XMLDefinitionFilter instances that define the makeup of XML nodes for different types. |
name | The value of the name attribute that defines the property name in the parent object. |
isProperty | When true, this indicates that the current XML node should be created as a property. This is usually indicated internally based on a filter. If isProperty is true, it is assumed that name is also provided. |
public static function parse(xml:XML, targetParent:Object = null):Object
xml | The xml to be parsed into an object. |
targetParent | The object in which the generated object will be defined, either as a property or a child display object. |
Page generated: 6:28 am on August 9, 2007