<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mesmotronic Blog &#187; Mesmotronic Multiuser Server</title>
	<atom:link href="http://blog.mesmotronic.com/index.php" rel="self" type="application/rss+xml" />
	<link>http://blog.mesmotronic.com</link>
	<description>Make it Mesmotronic</description>
	<lastBuildDate>Fri, 09 Dec 2011 22:05:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Too good for 2.5&#8230; Mesmotronic Multiuser Server 3 is coming!</title>
		<link>http://blog.mesmotronic.com/index.php/p/352</link>
		<comments>http://blog.mesmotronic.com/index.php/p/352#comments</comments>
		<pubDate>Sun, 09 May 2010 09:17:20 +0000</pubDate>
		<dc:creator>Mesmotronic</dc:creator>
				<category><![CDATA[Mesmotronic Multiuser Server]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[multiuser]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.mesmotronic.com/?p=352</guid>
		<description><![CDATA[Mesmotronic Multiuser Server 2.5 was supposed to be a stepping stone to 3, but as development progressed it became clear that all the cool new stuff being added would go far beyond a simple point-release.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png"><img class="aligncenter size-full wp-image-238" title="Mesmotronic Multiuser Server 2 (logo)" src="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png" alt="Mesmotronic Multiuser Server 2" width="320" height="40" /></a><br />
Mesmotronic Multiuser Server 2.5 was supposed to be a stepping stone to 3, but as development progressed it became clear that all the cool new stuff being added would go far beyond a simple point-release.</p>
<p>So, we&#8217;ve taken the decision to cancel 2.5 and continue development towards a new multi-platform release: Mesmotronic Multiuser Server 3.</p>
<p>More information coming soon&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mesmotronic.com/index.php/p/352/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get ready for Mesmotronic Multiuser Server 2.5</title>
		<link>http://blog.mesmotronic.com/index.php/p/270</link>
		<comments>http://blog.mesmotronic.com/index.php/p/270#comments</comments>
		<pubDate>Thu, 01 Apr 2010 14:09:45 +0000</pubDate>
		<dc:creator>Mesmotronic</dc:creator>
				<category><![CDATA[Mesmotronic Multiuser Server]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[multiuser]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.mesmotronic.com/?p=270</guid>
		<description><![CDATA[The next major release of Mesmotronic's real-time server solution has now entered the final stages of development and has been handed to our crack team of testers to put it through its paces.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png"><img class="aligncenter size-medium wp-image-238" title="Mesmotronic Multiuser Server 2 (logo)" src="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo-300x37.png" alt="Mesmotronic Multiuser Server 2" width="300" height="37" /></a><br />
The next major release of Mesmotronic&#8217;s real-time server solution has entered the final stages of development and has been handed to our crack team of testers to put it through its paces.</p>
<p><a title="Mesmotronic Multiuser Server" href="http://go.mesmotronic.com/multiuserserver">Mesmotronic Multiuser Server</a> 2.5 makes it even easier to add push data and real-time interactivity to you Flash, Flex and AIR applications by enabling ActionScript developers to build client and server functionality using nothing more than their existing knowledge and an easy-to-use <a title="ActionScript 3 API" href="http://docs.mesmotronic.com/multiuserserver/2/">ActionScript 3 API</a>.</p>
<p>Watch this space for further announcements.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mesmotronic.com/index.php/p/270/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mesmotronic Multiuser Server 2.0.5 update available</title>
		<link>http://blog.mesmotronic.com/index.php/p/237</link>
		<comments>http://blog.mesmotronic.com/index.php/p/237#comments</comments>
		<pubDate>Thu, 11 Mar 2010 16:21:57 +0000</pubDate>
		<dc:creator>Mesmotronic</dc:creator>
				<category><![CDATA[Mesmotronic Multiuser Server]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[multiuser]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.mesmotronic.com/?p=237</guid>
		<description><![CDATA[The latest update to Mesmotronic Multiuser Server 2 includes a number of technical updates to resolve theorectical, but never experienced, issues with Windows 7 and adds timestamps and the ability to remember your username/password in the admin console.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png"><img class="aligncenter size-full wp-image-238" title="Mesmotronic Multiuser Server 2 (logo)" src="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png" alt="Mesmotronic Multiuser Server 2" width="320" height="40" /></a><br />
The latest update to Mesmotronic Multiuser Server 2 includes a number of technical updates to resolve theorectical, but never experienced, issues with Windows 7 and adds timestamps and the ability to remember your username/password in the admin console.</p>
<p><a title="Mesmotronic Multiuser Server 2" href="http://go.mesmotronic.com/multiuserserver/">You can download the update here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mesmotronic.com/index.php/p/237/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Windows Server 2003 for Mesmotronic Multiuser Server</title>
		<link>http://blog.mesmotronic.com/index.php/p/77</link>
		<comments>http://blog.mesmotronic.com/index.php/p/77#comments</comments>
		<pubDate>Fri, 18 Dec 2009 00:56:18 +0000</pubDate>
		<dc:creator>Mesmotronic</dc:creator>
				<category><![CDATA[Mesmotronic Multiuser Server]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[multiuser]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.mesmotronic.com/?p=77</guid>
		<description><![CDATA[Whether you're intending to run Mesmotronic Multiuser Server 2 on a low-cost virtual private server (VPS) or a more powerful dedicated server, chances are that it will be running Windows Server 2003.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png"><img class="aligncenter size-full wp-image-238" title="Mesmotronic Multiuser Server 2 (logo)" src="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png" alt="Mesmotronic Multiuser Server 2" width="320" height="40" /></a><br />
Whether you&#8217;re intending to run <a title="MultiuserServer.com" href="http://www.multiuserserver.com/" target="_blank">Mesmotronic Multiuser Server 2</a> on a <a title="Low cost virtual private servers from 1and1" href="http://bit.ly/5aJMMZ" target="_blank">low-cost virtual private server (VPS)</a> or a more powerful <a title="Great value dedicated servers from 1and1" href="http://bit.ly/5aJMMZ" target="_blank">dedicated server</a>, chances are that it will be running Windows Server 2003.</p>
<p>Unlike the various desktop editions of Windows (XP, Vista and 7), you can&#8217;t simply an exception to the Windows Firewall settings or wait for the access dialogue to appear. Instead, you&#8217;ll need to <a title="How to configure Windows Server 2003's Local Security Settings" href="http://support.microsoft.com/kb/324036" target="_blank">update the Local Security Settings</a> by running &#8220;secpol.msc /s&#8221; from the command line or <em>Run&#8230; </em>option on the Start menu; by default, Mesmotronic Multiuser Server uses port 2040 for applications and 2080 for administration.</p>
<p>The next step is to make the Admin Console available remotely by creating a virtual directory on one of your websites which points to the <em>admin </em>folder in the Mesmotronic Multiuser Server installation directory:</p>
<ol>
<li>Open the Internet Information Services (IIS) Manager, found under <em>Start &gt; Administrative Tools</em></li>
<li>Expand <em>Web Sites</em>, in the left hand column, and click on the website that you would like to add the virtual directory to</li>
<li>Right click in an empty area of the right hand pane and select <em>New &gt; Virtual Directory&#8230; </em>from the menu</li>
<li>Use the wizard to create a new virtual directory, entering an alias on the second screen, e.g. &#8220;admin&#8221;, and the full path to the <em>admin </em>folder on the third, usually <em>C:\Program Files (x86)\Mesmotronic\Mesmotronic Multiuser Server 2\admin</em></li>
</ol>
<p>Finally, you should change the admin password, &#8220;password&#8221; by default, by opening the admin console in a web browser and selecting the <em>Configuration</em> tab.</p>
<p>And that&#8217;s all there is to it.</p>
<p>There&#8217;s more information about <a title="Getting started with Mesmotronic Multiuser Server 2" href="http://www.multiuserserver.com/gettingstarted/" target="_blank">how to configure Mesmotronic Multiuser Server here</a> and if you don&#8217;t already have a server, <a title="Great value VPS and dedicated Windows servers from 1and1" href="http://bit.ly/5aJMMZ" target="_blank">there are a wide range of options available here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mesmotronic.com/index.php/p/77/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to server-side applications for Mesmotronic Multiuser Server</title>
		<link>http://blog.mesmotronic.com/index.php/p/62</link>
		<comments>http://blog.mesmotronic.com/index.php/p/62#comments</comments>
		<pubDate>Thu, 10 Dec 2009 14:25:02 +0000</pubDate>
		<dc:creator>Mesmotronic</dc:creator>
				<category><![CDATA[Mesmotronic Multiuser Server]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[multiuser]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.mesmotronic.com/?p=62</guid>
		<description><![CDATA[Server-side applications can add vital functionality to multiuser applications and games created using Mesmotronic Multiuser Server 2, including the ability to load and save files, communicate between rooms and applications, and push data to clients.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png"><img class="aligncenter size-full wp-image-238" title="Mesmotronic Multiuser Server 2 (logo)" src="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png" alt="Mesmotronic Multiuser Server 2" width="320" height="40" /></a><br />
Server-side applications can add vital functionality to multiuser applications and games created using <a title="MultiuserServer.com" href="http://www.multiuserserver.com/" target="_blank">Mesmotronic Multiuser Server 2</a>, including the ability to load and save files, communicate between rooms and applications, and push data to clients.</p>
<p>A server-side application is a standard ActionScript 3 SWF like any other, except that it cannot display any graphics and extends the <a title="Mesmotronic Multiuser Server 2 API Reference" href="http://docs.mesmotronic.com/multiuserserver/2.0/" target="_blank">MultiuserServerApplication</a> class, rather than Sprite or MovieClip. Applications can therefore be created using any ActionScript 3 IDE, including Flex/Flash Builder, Flash CS3/4 and FlashDevelop.</p>
<p>In this tutorial, we&#8217;re going to create a very simple server-side application which sends, on request, a random colour to the client which the client will then apply to the stage. As usual, we&#8217;re assuming you have a reasonable working knowledge of ActionScript 3 and have Mesmotronic Multiuser Server installed locally, with the <a title="How to add the API to your library path" href="http://www.multiuserserver.com/gettingstarted/" target="_blank">API added to your library path</a>.</p>
<p>The first step in creating any new server-side application is to create a new document class which extends MultiuserServerApplication. Your initial class structure would typically look something like this:</p>
<pre>package
{
    import com.multiuserserver.server.MultiuserServerApplication;

    public class RandomColourApp extends MultiuserServerApplication
    {
        override public function main():void
        {
            // Entry point
        }
    }
}</pre>
<p>The <em>main </em>entry point is called immediately after the <em>application </em>property of your class (inherited from MultiuserServerApplication) has been initialized, enabling you to communicate with the outside world, and should be used in preference to a class constructor. Although we won&#8217;t be doing anything here in this tutorial, this is where you would normally configure your application and add any event listeners you may require.</p>
<p>By default, all calls made to the server by clients, via the MultiuserServerClient <em>call </em>method, will invoke public functions of your application class. So, to allow clients to request a random colour, we need to add a function called <em>getColour</em>:</p>
<pre>package
{
    import com.multiuserserver.server.MultiuserServerApplication;

    public class RandomColourApp extends MultiuserServerApplication
    {
        override public function main():void
        {
            // Entry point
        }

<span style="color: #3366ff;"><span style="color: #0000ff;">        public function getColour():uint
        {
            return Math.round(Math.random()*0xFFFFFF);
        }</span>
</span>    }
}</pre>
<p>Now that the function is in place, you simply need to publish your class in the usual way and copy the resulting SWF, <em>RandomColourApp.swf</em>, to a folder of the same name within the <em>applications</em> directory of Mesmotronic Multiuser Server. Based on the default installation folder, this would be:</p>
<pre> C:\Program Files\Mesmotronic\Mesmotronic Multiuser Server\applications\<span style="color: #0000ff;">RandomColourApp</span>\</pre>
<p>Once copied, your application is ready to go.</p>
<p>Now, all we need to do is create a simple client application to test that our server-side application works (the elements which relate to the server call are highlighted):</p>
<pre>package
{
    import com.multiuserserver.events.MultiuserServerEvent;
    import flash.events.IOErrorEvent;
    import flash.events.MouseEvent;

    public class RandomColourClient extends Sprite
    {
        public var client:MultiuserServerClient;

        public function RandomColourClient()
        {
            client = new MultiuserServerClient();
            client.addEventListener(MultiuserServerEvent.CONNECT, onConnect);
            client.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
            client.delegate = this;
            client.connect("localhost", 2040, "RandomColourApp", 10);

            stage.addEventListener(MouseEvent.CLICK, onClick);
        }

        public function onConnect(event:MultiuserServerEvent):void
        {
            trace("Connected!");
        }

        public function onIOError(event:Event):void
        {
            trace("Connection Error.");
        }

        public function onClick(event:MouseEvent):void
        {
            <span style="color: #0000ff;">client.call("getColour", null, "setColour");
</span>        }

        <span style="color: #0000ff;">public function setColour(colour:uint):void
        {
            graphics.clear();
            graphics.beginFill(colour);
            graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
        }</span>
    }
}</pre>
<p>Publish the class above and you will find that every time you click on the stage it will change to the colour received from the server!</p>
<p>Obviously, this is just scratching the surface of what&#8217;s possible with server-side applications, but it should give you a good idea of how basic client-server interaction can be implemented.</p>
<p>We&#8217;ll be taking a look at more advanced functionality at a later date, but if you&#8217;d like to find out more in the mean time, there are several examples included with your Mesmotronic Multiuser Server installation (follow the link on your start menu), which are also <a title="MultiuserServer.com" href="http://www.multiuserserver.com/" target="_blank">available as a separate download</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mesmotronic.com/index.php/p/62/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex data binding with Mesmotronic Multiuser Server</title>
		<link>http://blog.mesmotronic.com/index.php/p/54</link>
		<comments>http://blog.mesmotronic.com/index.php/p/54#comments</comments>
		<pubDate>Tue, 08 Dec 2009 13:41:02 +0000</pubDate>
		<dc:creator>Mesmotronic</dc:creator>
				<category><![CDATA[Mesmotronic Multiuser Server]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[multiuser]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.mesmotronic.com/?p=54</guid>
		<description><![CDATA[If you're creating client applications for Mesmotronic Multiuser Server 2 in Flex 3 or 4, it's worth noting that almost all of the properties of both the MultiuserServerClient and MultiuserServerClientInfo classes are bindable.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png"><img class="aligncenter size-full wp-image-238" title="Mesmotronic Multiuser Server 2 (logo)" src="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png" alt="Mesmotronic Multiuser Server 2" width="320" height="40" /></a><br />
If you&#8217;re creating client applications for Mesmotronic Multiuser Server 2 in Flex 3 or 4, it&#8217;s worth noting that almost all of the properties of both the MultiuserServerClient and MultiuserServerClientInfo classes are bindable.</p>
<p>Why is this useful? It means you can create things like connection status indicators or display the client and room ID without having to add any additional event handlers to your code.</p>
<p>For example, if you have a button that should only be available to users when they&#8217;re connected to the server, you can simply bind the <em>enabled</em> property of the button to the <em>connected</em> property of an instance of MultiuserServerClient, in this case <em>client</em>:</p>
<pre>&lt;mx:Button label="Enabled when connected" enabled="{client.connected}" /&gt;</pre>
<p>Or, alternatively:</p>
<pre>&lt;mx:Binding source="client.connected" destination="myButton.enabled" /&gt;</pre>
<p>This is equally true of all MultiuserServerClientInfo class properties, which is accessed via the <em>info </em>property of any MultiuserServerClient instance:</p>
<pre>&lt;mx:Label text="{client.connected ? 'You are in room '+client.info.room : 'You are not connected'}" /&gt;</pre>
<p>If you&#8217;re new to Flex data binding, <a title="Flex Quick Start: Handling data" href="http://www.adobe.com/devnet/flex/quickstart/using_data_binding/" target="_blank">Adobe has a quick start guide here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mesmotronic.com/index.php/p/54/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with Mesmotronic Multiuser Server using Flex</title>
		<link>http://blog.mesmotronic.com/index.php/p/36</link>
		<comments>http://blog.mesmotronic.com/index.php/p/36#comments</comments>
		<pubDate>Fri, 04 Dec 2009 18:39:08 +0000</pubDate>
		<dc:creator>Mesmotronic</dc:creator>
				<category><![CDATA[Mesmotronic Multiuser Server]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[multiuser]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.mesmotronic.com/?p=36</guid>
		<description><![CDATA[In this tutorial, we'll be creating a simple peer-to-peer chat application using Mesmotronic Multiuser Server 2 and Flex 3 MXML.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png"><img class="aligncenter size-full wp-image-238" title="Mesmotronic Multiuser Server 2 (logo)" src="http://blog.mesmotronic.com/wp-content/uploads/2010/03/multiuserserver2_logo.png" alt="Mesmotronic Multiuser Server 2" width="320" height="40" /></a><br />
In this tutorial, we&#8217;ll be creating a simple peer-to-peer chat application using <a title="Download Mesmotronic Multiuser Server" href="http://www.multiuserserver.com/" target="_blank">Mesmotronic Multiuser Server 2</a> and Flex 3 MXML.</p>
<p>We&#8217;re assuming that you already have at least a basic knowledge of MXML and ActionScript 3, that Mesmotronic Multiuser Server is installed locally and you have <a title="How to get started with the Mesmotronic Multiuser Server API" href="http://www.multiuserserver.com/gettingstarted/" target="_blank">made the ActionScript API available to your chosen IDE</a>. If you don&#8217;t already have an MXML editor, you can follow this tutorial using either <a title="Download FlashDevelop" href="http://www.flashdevelop.org/" target="_blank">FlashDevelop</a> or the trial version of <a title="Download Flex Builder" href="http://go.adobe.com/flex" target="_blank">Flex Builder</a>.</p>
<p>Regardless of which editor you&#8217;re using, the first step is to create a new Flex Project and open the main MXML file (usually called <em>main.mxml</em>, or similar).</p>
<p>First, create the various MXML elements of the application, starting by adding a new namespace declaration to the Application tag to allow you to instantiate classes from the Mesmotronic Multiuser Server API using MXML:</p>
<pre>&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  <span style="color: #3366ff;">xmlns:client="com.multiuserserver.client.*"</span>&gt;</pre>
<p>Next, add a new MXML tag to instantiate the MultiuserServerClient class, setup the event listeners and assign a delegate:</p>
<pre>&lt;client:MultiuserServerClient
  id="client"
  delegate="{this}"
  connect="onConnect(event);"
  clientConnect="onClientConnect(event);"
  clientDisconnect="onClientDisconnect(event);"
  ioError="onIOError(event);"
  /&gt;</pre>
<p>The <em>delegate </em>property indicates the class or object that contains functions you would like to make available to other clients and/or the server, in this case we&#8217;re making all of the public functions of the current class available.</p>
<p>The <em>connect </em>event is dispatched when you initially connect to the server, <em>clientConnect</em> when a new client joins the room (including you), <em>clientDisconnect </em>when a client leaves the room and <em>ioError </em>when a connection error occurs.</p>
<p>Next, create a Panel with a very simple form inside of it, made up of a large TextArea to display messages, a TextInput field to input messages and a button you can press to send messages which calls a function called <em>showMessage</em> on all of the clients in the current room using the <em>run </em>method of the MultiuserServerClient class:</p>
<pre>&lt;mx:Panel id="panel" title="Mesmotronic Multiuser Server Example" status="Connecting..."&gt;
  &lt;mx:Form width="100%" defaultButton="{input_btn}"&gt;
    &lt;mx:TextArea id="output_txt" width="400" height="160" editable="false" /&gt;
    &lt;mx:TextInput id="input_txt" width="400" /&gt;
    &lt;mx:Button id="input_btn" width="100" label="Send"
      click="client.run('showMessage', [client.info.clientIndex, input_txt.text]); input_txt.text = '';" /&gt;
  &lt;/mx:Form&gt;
&lt;/mx:Panel&gt;</pre>
<p>The final MXML element is a <em>creationComplete </em>event in the Application tag. This will allow you to connect automatically once your Flex application has finished loading:</p>
<pre>&lt;mx:Application
  xmlns:mx="http://www.adobe.com/2006/mxml"
  xmlns:client="com.multiuserserver.client.*"
  <span style="color: #3366ff;">creationComplete="client.connect('localhost', 2040, 'FlexExample', 10);"</span>
  &gt;</pre>
<p>Finally, we need to create the ActionScript functions necessary to handle the various MultiuserServerClient events:</p>
<pre>&lt;mx:Script&gt;
  &lt;![CDATA[
    import com.multiuserserver.events.MultiuserServerEvent;
    import flash.events.IOErrorEvent;

    public function onConnect(event:MultiuserServerEvent):void
    {
      panel.status = "Connected";
      output_txt.text += "Hi user "+client.info.clientIndex+", welcome to room "+client.info.room+"!\n";
    }

    public function onClientConnect(event:MultiuserServerEvent):void
    {
      if (event.clientIndex != client.info.clientIndex)
        output_txt.text += "User "+event.clientIndex+" has joined the room.\n";
    }

    public function onClientDisconnect(event:MultiuserServerEvent):void
    {
      output_txt.text += "User "+event.clientIndex+" has left the room.\n";
    }

    public function onIOError(event:IOErrorEvent):void
    {
      panel.status = "Unable to contact server";
      output_txt.text = "It was not possible to connect to the server, please ensure that Mesmotronic Multiuser Server 2 is running.";
    }

    public function showMessage(clientIndex:int, text:String):void
    {
      output_txt.text += "[User "+clientIndex+"] "+text+"\n";
      output_txt.validateNow();
      output_txt.verticalScrollPosition = output_txt.maxVerticalScrollPosition;
    }
  ]]&gt;
&lt;/mx:Script&gt;</pre>
<p>As you can see, there&#8217;s nothing complicated involved: the ActionScript functions simply populate the TextArea and update the Panel&#8217;s status. If you prefer, much of this functionality can be included within your MXML declarations.</p>
<p>And that&#8217;s it. Now all you need to do is run your application and send yourself a few messages to try it out!</p>
<p>For more information about the events, properties and methods of the MultiuserServerClient class, <a title="Mesmotronic Multiuser Server 2 API Reference" href="http://docs.mesmotronic.com/multiuserserver/2.0/" target="_blank">take a look at the API reference</a> or browse through the examples included with your Mesmotronic Multiuser Server installation, a link to which can be found on your Start Menu.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mesmotronic.com/index.php/p/36/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with Mesmotronic Multiuser Server using ActionScript 3</title>
		<link>http://blog.mesmotronic.com/index.php/p/24</link>
		<comments>http://blog.mesmotronic.com/index.php/p/24#comments</comments>
		<pubDate>Thu, 03 Dec 2009 11:53:38 +0000</pubDate>
		<dc:creator>Mesmotronic</dc:creator>
				<category><![CDATA[Mesmotronic Multiuser Server]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[multiuser]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.mesmotronic.com/?p=24</guid>
		<description><![CDATA[This tutorial shows how to create a basic peer-to-peer application to track other users' mouse positions using Mesmotronic Multiuser Server 2 and ActionScript 3 (AS3).]]></description>
			<content:encoded><![CDATA[<p>We believe that Mesmotronic Multiuser Server 2 is the quickest, easiest way to create real-time multiuser and with the Adobe Flash Platform, including Adobe Flash, Flex and AIR, and if you haven&#8217;t already installed Mesmotronic Multiuser Server, you can <a title="Download Mesmotronic Multiuser Server 2" href="http://www.multiuserserver.com/" target="_blank">download the latest version here</a>.</p>
<p>This tutorial shows how to create a basic peer-to-peer application to track other users&#8217; mouse positions using Mesmotronic Multiuser Server 2 and ActionScript 3 (AS3), so it&#8217;ll work regardless of whether you&#8217;re using <a title="Flash" href="http://go.adobe.com/flash" target="_blank">Flash</a>, <a title="FlashDevelop" href="http://www.flashdevelop.org/" target="_blank">FlashDevelop</a> or <a title="Flex Builder" href="http://go.adobe.com/flex" target="_blank">Flex Builder</a>. We&#8217;ll take a look at Flex/MXML and client-server applications at a later date.</p>
<p>We&#8217;re assuming at this point that you&#8217;ve already installed Mesmotronic Multiuser Server 2, <a title="How to get started with the Mesmotronic Multiuser Server API" href="http://www.multiuserserver.com/gettingstarted/" target="_blank">made the ActionScript API available to your chosen IDE</a> and have a reasonable understanding of AS3.</p>
<p>The first thing you need to do is create a new document class which extends <em>flash.display.Sprite</em>, let&#8217;s call it Main, and import the classes you&#8217;ll need to use the Mesmotronic Multiuser Server API:</p>
<pre>import com.multiuserserver.client.MultiuserServerClient;
import com.multiuserserver.events.MultiuserServerEvent;
import flash.events.IOErrorEvent;</pre>
<p>Next, declare an instance of the MultiuserServerClient class. Once instantiated, this will handle all of the communication with the other clients:</p>
<pre>public var client:MultiuserServerClient;</pre>
<p>You&#8217;re now ready to set up your connection by instantiating the MultiuserServerClient class and configure your connection. For this example, we&#8217;ll do everything in the class constructor, but the chances are you&#8217;ll want to do things like connect via a button in your own multiuser applications:</p>
<pre>public function Main()
{
    client = new MultiuserServerClient();
    client.addEventListener(MultiuserServerEvent.CONNECT, onConnect);
    client.addEventListener(MultiuserServerEvent.CLIENT_DISCONNECT, onClientDisconnect);
    client.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
    client.delegate = this;
    client.connect("localhost", 2040, "AS3Tutorial", 10);
}</pre>
<p>The events we&#8217;re using are pretty self-explanatory: CONNECT is dispatched when you initially connect to the server, CLIENT_DISCONNECT when a client disconnects and IO_ERROR if there&#8217;s a problem with your connection.</p>
<p>The <em>delegate </em>property indicates where the functions you&#8217;d like to make available to other clients and/or the server live. In this case, we&#8217;re setting it to the current class.</p>
<p>The <em>connect </em>method has 4 required parameters: server name (or IP address), server port (2040 is the default), application name (this must be unique for each application you create) and the maximum number of clients that can be in each room at any give time.</p>
<p>In this example, we&#8217;re assuming that you&#8217;ll just want to test locally, but if you&#8217;d like to test over a network, simply change <em>localhost </em>to the name or IP address of the computer running Mesmotronic Multiuser Server.</p>
<p>Everything you need to connect to Mesmotronic Multiuser Server is now in place, so now we need to create the properties and methods to actually make something happen once you&#8217;re connected.</p>
<p>First, we import a the MouseEvent class:</p>
<pre>import flash.events.MouseEvent;</pre>
<p>Then we create the properties and methods we need to bring the application to life:</p>
<pre>public var cursors:Array = [];

// Announce the connection and start to broadcast your cursor position
public function onConnect(event:MultiuserServerEvent):void
{
    trace("You've connected to Mesmotronic Multiuser Server!");
    stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}

// Remove the blobs when clients leave
public function onClientDisconnect(event:MultiuserServerEvent):void
{
    var cursor:Sprite = cursors[event.clientIndex] as Sprite;
    removeChild(cursor);
    cursors[event.clientIndex] = null;
}

public function onIOError(event:IOErrorEvent):void
{
    trace("Connection Error: is Mesmotronic Multiuser Server installed and running?");
}

// Broadcast your mouse position
public function onMouseMove(event:MouseEvent):void
{
    // The run method is used to call a function on 1 or more clients
    client.run("setCursorPosition", [client.info.clientIndex, mouseX, mouseY]);
}

// This is the function that clients call to let you know where their mouse cursor is
public function setCursorPosition(clientIndex:uint, cursorX:Number, cursorY:Number):void
{
    var cursor:Sprite;

    // Create a coloured blob to represent the client's cursor if it doesn't exist
    if (!cursors[clientIndex])
    {
        cursor = new Sprite();
        cursor.graphics.beginFill(0xCCCCCC/client.info.clientsPerRoom*clientIndex);
        cursor.graphics.drawCircle(0,0,10);

        cursors[clientIndex] = addChild(cursor);
    }

    cursor = cursors[clientIndex] as Sprite;
    cursor.x = cursorX;
    cursor.y = cursorY;
}</pre>
<p>That&#8217;s it! Just publish the class in the normal way, open up a few copies of the SWF and watch in amazement as the blobs follow your cursor around the screen. It really is that easy.</p>
<p>For more information about the events, properties and methods of the MultiuserServerClient class, <a title="Mesmotronic Multiuser Server 2 API Reference" href="http://docs.mesmotronic.com/multiuserserver/2.0/" target="_blank">take a look at the API reference</a> or browse through the examples included with your Mesmotronic Multiuser Server installation, a link to which can be found on your Start Menu.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mesmotronic.com/index.php/p/24/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

