Each layer has its own xml file describing its contents. A Layer contains sublayers, which themselves contain components. So the xml file describes these 3 different types of elements and their states.

A subLayer has an “id” attribute which is its name.
<layer><subLayers><subLayer id=”fade”><components> …
Furthermore, each component and its actions must be described:

as2Url is the URL of the component for AS2, relative to the root of silex.
html5Url is the same thing but for the HTML5 version of a component. It is of the form pathToTheLibraryDirectory#nameOfTheClassToBeInstanciated.
className is an identifier for the component.
properties and actions are described below.
Here is a short example:
<component> <as2Url>plugins/baseComponents/as2/org.silex.ui.players.Text.swf</as2Url> <className>org.silex.ui.players.Text</className> <properties>...</properties> <actions>...</actions> </component>
Properties
The properties node contains one node per property. Each property node can have a “type” attribute, which can be worth String, Float, Integer or Boolean. If the attribute is not present, it is assumed that the property is a string.
<height type=”Float”>100.15</height>
Actions
The actions node contains one node per action. The action node has a functionName child node, a modifier child node, and a parameters childNode. The parameters node contains an array of parameter nodes, which each contain a string.

<actions> <action> <functionName>alert</functionName> <modifier>onRelease</modifier> <parameters> <parameter>hi</parameter> </parameters> </action> </actions>
You can download an example XML file: start.xml.
Parsing
We have created an haXe API to parse this new file format. It is located in the org.silex.publication package. Its documentation can be found here. You will likely want to use the LayerModel.load function.
This function takes the path to the publication’s directory and the name of the layer you want to parse. It then returns a LayerModel that you can access and manipulate.
Here is a simple example listing subLayers and the name of components of the start layer from the myPublication publication.
import org.silex.publication.LayerModel;
class ListComponents
{
public static function main(): Void
{
var startLayer = LayerModel.load("/Users/benjamin/250211/trunk/silex_server/contents/mypublication", "start");
for(subLayer in startLayer.subLayers)
{
php.Lib.println("SubLayer " + subLayer.id);
php.Lib.println("---");
for(component in subLayer.components)
{
php.Lib.println(component.properties.get("playerName") + "(" + component.className + ")");
}
}
}
}
You can also modify layers and save them using the save function. You need to give it the path of the publication as a parameter. It will save the data according to the name property of the LayerModel object.
So, if you have a LayerModel object with its name property set to start2 and call myLayer.save(“contents/mypublication”); it will be saved as contents/mypublication/start2.xml.





Lexa
Ariel, tu devrais mettre un xml d’exemple à downloader ici