Flex data binding with Mesmotronic Multiuser Server

Mesmotronic Multiuser Server 2
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.

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.

For example, if you have a button that should only be available to users when they’re connected to the server, you can simply bind the enabled property of the button to the connected property of an instance of MultiuserServerClient, in this case client:

<mx:Button label="Enabled when connected" enabled="{client.connected}" />

Or, alternatively:

<mx:Binding source="client.connected" destination="myButton.enabled" />

This is equally true of all MultiuserServerClientInfo class properties, which is accessed via the info property of any MultiuserServerClient instance:

<mx:Label text="{client.connected ? 'You are in room '+client.info.room : 'You are not connected'}" />

If you’re new to Flex data binding, Adobe has a quick start guide here.