<?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>The Back Room &#187; Multitouch in Flash</title>
	<atom:link href="http://backroom.bostonproductions.com/?feed=rss2&#038;tag=multitouch-in-flash" rel="self" type="application/rss+xml" />
	<link>http://backroom.bostonproductions.com</link>
	<description>Boston Productions' Museum Technology Journal</description>
	<lastBuildDate>Tue, 31 Aug 2010 21:50:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Multiple Mice With Adobe Flash/Air/Flex</title>
		<link>http://backroom.bostonproductions.com/?p=35</link>
		<comments>http://backroom.bostonproductions.com/?p=35#comments</comments>
		<pubDate>Fri, 10 Apr 2009 14:16:24 +0000</pubDate>
		<dc:creator>Charles</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Explore Hershey]]></category>
		<category><![CDATA[Flash Multiple Mice]]></category>
		<category><![CDATA[Multitouch in Flash]]></category>
		<category><![CDATA[SDG]]></category>
		<category><![CDATA[SDGToolkit]]></category>

		<guid isPermaLink="false">http://backroom.bostonproductions.com/?p=35</guid>
		<description><![CDATA[When I first started working for Boston Productions, we were just starting development on the interactive exhibits for The Hershey Story.  The exhibit called Explore Hershey is a town model of Hershey, PA that features four user stations that have to be able to simultaneously interact with the map of the town.  This means that [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_37" class="wp-caption alignleft" style="width: 160px"><a href="http://backroom.bostonproductions.com/wp-content/uploads/2009/04/multimouseflash11.jpg"><img class="size-thumbnail wp-image-37" title="Using Multiple Trackballs in Flash" src="http://backroom.bostonproductions.com/wp-content/uploads/2009/04/multimouseflash11-150x150.jpg" alt="There is a trackball at each station that is seen by the computer running the Map application as four mice" width="150" height="150" /></a><p class="wp-caption-text">There is a trackball at each station that is seen by the computer running the Map application as four mice</p></div>
<p>When I first started working for Boston Productions, we were just starting development on the interactive exhibits for <a title="The Hershey Story" href="http://www.hersheystory.org">The Hershey Story</a>.  The exhibit called Explore Hershey is a town model of Hershey, PA that features four user stations that have to be able to simultaneously interact with the map of the town.  This means that somehow we had to allow four mice to simultaneously interact with one Flash application.</p>
<p>After a large survey of how people were handling multi-mouse applications in all areas of programming, I found out academia actually calls using multiple-mice “SDG” or Single Display Groupware.  A decent amount of work is indirectly going into using multiple mice right now due to the <a title="Johnny Lees Multitouch Wii Projects" href="http://johnnylee.net/projects/wii/">proliferation of multiple touch interactive displays</a>.</p>
<p>Flash cannot do multiple mouse interaction on its own.  It needs help from another program that has more direct ties to the underlying hardware of the system you are using.<br />
Based on the survey of currently available SDG applications, the most usable starting point with the best documentation I came across was the <a title="SDGToolkit" href="http://grouplab.cpsc.ucalgary.ca/cookbook/index.php/Toolkits/SDGToolkit">University of Calgary’s SDGToolkit</a>.  The SDGToolkit can be integrated into many of the Microsoft programming languages as a <a title="COM Objects Explained" href="http://www.technogumbo.com/2008/07/Windows-Developer-Newbie-Secrets/">COM Object</a> which basically allows you to have multiple mouse applications running in a Windows environment in a matter of minutes.  I chose to use Microsoft Visual C# to write the SDG application that is in use at Hershey.</p>
<p><strong>So how do we use multiple mice in flash then?</strong></p>
<div id="attachment_38" class="wp-caption alignright" style="width: 160px"><strong><strong><a href="http://backroom.bostonproductions.com/wp-content/uploads/2009/04/multimouseflash2.jpg"><img class="size-thumbnail wp-image-38" title="multimouseflash2" src="http://backroom.bostonproductions.com/wp-content/uploads/2009/04/multimouseflash2-150x150.jpg" alt="There are four stations and four projection screens.  In total five computers run this interactive." width="150" height="150" /></a></strong></strong><p class="wp-caption-text">There are four stations and four projection screens.  In total five computers run this interactive.</p></div>
<p>The secret is that you need to have the SDGToolkit based application handle all interaction with the mice and send that to the Flash application.  Another option is that you can actually embed a flash application inside a .NET based forms application using another COM Component called the “Macromedia Flash Factory Object”.  For our situation, we decided this would not be a good option because we had to run the Flash Application full screen.</p>
<p>The way chosen to send commands from the .NET application to Flash was through sockets.  I crafted the .NET application in such a way that it would use threads to easily handle multiple connects and disconnects from the Flash application.  A great starting point for multi-threaded socket programming in .NET is the <a title="Multithreaded Chat Server" href="http://www.codeproject.com/KB/IP/chatserver.aspx">Multithreaded Chat Server at the CodeProject by member Sidzone</a>. The commands I send over the socket connection to flash several times a second as a string look like this: &lt;*M0,337,-142,1,*M1,209,198,0,*M2,0,0,0,*M3,0,0,0,*&gt;.  They report the screen x,y coordinates of each mouse.  The third number is a 0 for mouse not pressed and 1 for mouse pressed.</p>
<p>In the Flash Application, I used <a title="Actionscript 3 Socket Class" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/Socket.html">the Socket class</a> in order to connect to and receive commands from the .NET application as a comma delimited string.  I decided not to use the XMLSocket class because the extra steps needed by both sides in setup seemed onerous for the utilitarian string I would be sending to flash.  Once the command string is received by flash, I parse it, then use events to pass it through a series of classes which allow the commands to be crafted into targets moving around on the stage and interacting with buildings.</p>
]]></content:encoded>
			<wfw:commentRss>http://backroom.bostonproductions.com/?feed=rss2&amp;p=35</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
