go back to the articles list

Is there any static variable type available in server side?

Question:
Is there any static variable type available in server side ? so that I can change that variable globally.

Answer:
Yes. With FMS2 you can actually set variables in the application.xml file. Now if you set these variables in this file and put the application.xml file in the application directory, the variables you set will be available to instances of that application only. Not any others.

If you don't put an application.xml file in the application directory of the application that you are running, then FMS will default to the level higher which would be the conf directory for the virtualhost you are running and look in there. That's where we are going to set our variable.

So, open up the application.xml file in some text editor and jump down to the tag
<code><JSEngine></code>

In there we are going to add a couple of new tags:
<code><ApplicationObject></code>

Inside there:
<code><config></code>

And in there we are going to add a super user tag and put my name in it:
<b>superUser</b>

<i>Graeme Bull</i>

So it looks like this:
<code>
<JSEngine>

     <ApplicationObject>

          <config>

               <superUser>Graeme Bull</superUser>

          </config>

     </ApplicationObject>

</JSEngine>
</code>

Now, save the file, restart the server and make a main.asc file because we are now going to trace this value out:

application.onAppStart = function(){
     trace("The Super User is: " + application.config.superUser);
}

Now when you start up the application you should see the following trace:

<b>The Super User is: Graeme Bull</b>

That's it :)

Posted by: Graeme Bull on Feb 04, 2006

Share This Article

STi Chat for Wowza Media Server with Flex | Foundation Edition v4

STi Chat for Wowza Media Server with Flex | Foundation Edition v4

This is a new and improved basic video/audio/text chat application with the ability to invite other users to a private room. The Foundation Edition is meant to give developers the building blocks they need to learn, as well as an entry level solution for those needing a basic chat system. The source code is in AS3 and MXML with the Flex 4.5 SDK. We will be working on more features for the chat as we go and all are free.

$129 Buy Now