You
can define properties for the server-side Application object in
the server’s Application.xml configuration files. If you define
properties in the default Application.xml file, the properties are
available for all applications on a virtual host. If you define
properties in an Application.xml file in an application folder,
the properties are available only for that application.
To define a property, create an XML tag in the JSEngine section
of the Application.xml file. The property name corresponds to the
tag’s name, and the property value corresponds to the tag’s contents.
For example,
the following XML fragment defines the properties user_name and dept_name,
with the values jdoe and engineering,
respectively:
<Application>
<JSEngine>
<config>
<user_name>jdoe</user_name>
<dept_name>engineering</dept_name>
</config>
</JSEngine>
</Application>
To access the property in server-side code, use the syntax in
either of these examples:
application.config.prop_name
application.config["prop_name"]
Note: The properties you define are accessible from application.config.property,
not from application.property.
For example, given the previous XML fragment, the following trace() statements
are valid:
trace("I am " + application.config.user_name + " and I work in the " + application.config.dept_name + " department.");
trace("I am " + application.config["user_name"] + " and I work in the " + application.config["dept_name"] + " department.");
The output from either statement would be as follows:
I am jdoe and I work in the engineering department.
You can also use environment variables and symbols you define
in the substitution.xml file. For example, assume that the environment
variable COMPUTERNAME is equal to jsmith01,
and you have defined a symbol named DEPT in the
substitution.xml file:
<Root>
<Symbols>
<DEPT>Engineering</DEPT>
</Symbols>
</Root>
In addition, the following XML appears in the Application.xml
file:
<Application>
<JSEngine>
<config>
<compName>${%COMPUTERNAME%}</compName>
<dept>${DEPT}</dept>
</config>
</JSEngine>
</Application>
In a server-side script, the following trace statements
are valid:
trace("My computer's name is: " + application.config.compName);
trace("My department is: " + application.config.dept);
The output is as follows:
My computer's name is: jsmith01
My department is: Engineering
Note: Server-side ActionScript trace()statements
display in the Live Log panel of the Administration Console.