<?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>polyGeek.com &#187; Remote SharedObjects</title>
	<atom:link href="http://polygeek.com/tag/remote-sharedobjects/feed" rel="self" type="application/rss+xml" />
	<link>http://polygeek.com</link>
	<description>polyGeek (noun) person with many geek related talents.</description>
	<lastBuildDate>Tue, 27 Jul 2010 17:13:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Creating a user poll using Flash Media Server and Remote SharedObjects</title>
		<link>http://polygeek.com/1109_flex_creating-a-user-poll-using-flash-media-server-and-remote-sharedobjects</link>
		<comments>http://polygeek.com/1109_flex_creating-a-user-poll-using-flash-media-server-and-remote-sharedobjects#comments</comments>
		<pubDate>Thu, 23 Oct 2008 17:00:45 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flash Media Server]]></category>
		<category><![CDATA[Remote SharedObjects]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1109</guid>
		<description><![CDATA[NOTE: this example only works when Flash Media Server is running on my PC and it&#8217;s connected to the Internet. Flash Media Server is good for a lot more than just streaming video and audio. With Remote Shared Objects you can store persistent data on the server to do things like create chat applications or [...]]]></description>
			<content:encoded><![CDATA[<p>NOTE: this example only works when Flash Media Server is running on my PC and it&#8217;s connected to the Internet.</p>
<p>Flash Media Server is good for a lot more than just streaming video and audio. With Remote Shared Objects you can store persistent data on the server to do things like create chat applications or a user poll.</p>
<p>I&#8217;ve created lots of polls in the past using AMFPHP &#8211; there&#8217;s one sitting to the far right column -&gt;. It&#8217;s easy to do and very reusable. Storing data in a database has many advantages over using Remote Shared Objects but the RSO approach has one very distinct advantage: it automatically updates while you&#8217;re looking at the data. Check out the poll below. Submit your vote and then open this page in another Tab/Window ( I&#8217;d suggest opening in another Window so that you can see both at the same time. ) Submit you vote again and see it update the chart from your original vote. Cool, eh?</p>
<p>And the best thing of all is that it doesn&#8217;t take any extra code to achieve that. It pretty much comes with. It&#8217;s just a combination of the Sync event on the RSO and DataBinding.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1109_RemoteSharedObjects_poll_post_1369025470"
			class="flashmovie"
			width="500"
			height="460">
	<param name="movie" value="/flex/1109_RemoteSharedObjects_poll/_1109_RemoteSharedObjects_poll_post.swf" />
	<param name="wmode" value="normal" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/flex/1109_RemoteSharedObjects_poll/_1109_RemoteSharedObjects_poll_post.swf"
			name="fm__1109_RemoteSharedObjects_poll_post_1369025470"
			width="500"
			height="460">
		<param name="wmode" value="normal" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="/flex/1109_RemoteSharedObjects_poll/srcview/index.html">view source</a></td>
</tr>
</tbody>
</table>
<p><strong>Getting Dirty</strong><br />
This example is very similar to my first two RSO examples except that I&#8217;m storing an ArrayCollection of Data Transfer Objects in the RSO. In practice it is no different than storing a String, Number, etc. except that FMS doesn&#8217;t actually notice that the value of the RSO has changed when you use <em>setProperty()</em>.</p>
<p>All you have to do after calling <em>setProperty()</em> is call the <em>setDirty()</em> method on the RSO and that will do the trick for you. I have an entire <a href="http://polygeek.com/1251_flex_getting-dirty-with-remote-sharedobjects">post dedicated to <em>setDirty</em> with a simple example</a>.</p>
<p><strong>The best of both worlds</strong><br />
It would be very easy &#8211; if you have FMS and AMFPHP going for you &#8211; to set up a killer poll that used a database to store the data but used Remote SharedObjects to connect concurrent users so that when one user updated it would fire the Sync event for everyone viewing the poll and then we could go to the database to refresh the data. More about that later.</p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="dan@polygeek.com" /><input type="hidden" name="return" value="http://polygeek.com/thank-you-for-donating" /><input type="hidden" name="item_name" value="Nothing says thanks better than a few $$$. :) for Creating a user poll using Flash Media Server and Remote SharedObjects" /><input type="hidden" name="currency_code" value="USD" /><input type="hidden" name="amount" value="" /><input type="image" src="http://polygeek.com/wp-content/plugins/buy-me-beer/icon_beer.gif" align="left" alt="tip-jar" title="tip-jar" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=dan@polygeek.com&amp;currency_code=USD&amp;amount=&amp;return=http://polygeek.com/thank-you-for-donating&amp;item_name=Nothing+says+thanks+better+than+a+few+$$$.+:)+for+Creating+a+user+poll+using+Flash+Media+Server+and+Remote+SharedObjects" target="paypal"><SPAN STYLE="font-size: x-small">If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.</span></a></p><p align="left"><a class="tt" href="http://twitter.com/home/?status=Creating+a+user+poll+using+Flash+Media+Server+and+Remote+SharedObjects+http://bit.ly/72NYYS" title="Post to Twitter"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-twitter-big1.png" alt="Post to Twitter" /></a> <a class="tt" href="http://delicious.com/post?url=http://polygeek.com/1109_flex_creating-a-user-poll-using-flash-media-server-and-remote-sharedobjects&amp;title=Creating+a+user+poll+using+Flash+Media+Server+and+Remote+SharedObjects" title="Post to Delicious"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-delicious-big1.png" alt="Post to Delicious" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://polygeek.com/1109_flex_creating-a-user-poll-using-flash-media-server-and-remote-sharedobjects&amp;t=Creating+a+user+poll+using+Flash+Media+Server+and+Remote+SharedObjects" title="Post to Facebook"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-facebook-big1.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://polygeek.com/1109_flex_creating-a-user-poll-using-flash-media-server-and-remote-sharedobjects&amp;title=Creating+a+user+poll+using+Flash+Media+Server+and+Remote+SharedObjects" title="Post to Reddit"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-reddit-big1.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://polygeek.com/1109_flex_creating-a-user-poll-using-flash-media-server-and-remote-sharedobjects&amp;title=Creating+a+user+poll+using+Flash+Media+Server+and+Remote+SharedObjects" title="Post to StumbleUpon"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-su-big1.png" alt="Post to StumbleUpon" /></a></p><p><a href="http://polygeek.com/1109_flex_creating-a-user-poll-using-flash-media-server-and-remote-sharedobjects" rel="bookmark">Creating a user poll using Flash Media Server and Remote SharedObjects</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on October 23, 2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1109_flex_creating-a-user-poll-using-flash-media-server-and-remote-sharedobjects/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Getting Dirty with Remote SharedObjects</title>
		<link>http://polygeek.com/1251_flex_getting-dirty-with-remote-sharedobjects</link>
		<comments>http://polygeek.com/1251_flex_getting-dirty-with-remote-sharedobjects#comments</comments>
		<pubDate>Wed, 22 Oct 2008 17:00:26 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flash Media Server]]></category>
		<category><![CDATA[Remote SharedObjects]]></category>
		<category><![CDATA[setDirty]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1251</guid>
		<description><![CDATA[NOTE: this example only works when Flash Media Server is running on my PC and it&#8217;s connected to the Internet. Here&#8217;s another of those lessons that I learned after hours of trying to figure out why my code wasn&#8217;t working. In this case my code just wasn&#8217;t dirty enough. :-) What had happened was that [...]]]></description>
			<content:encoded><![CDATA[<p>NOTE: this example only works when Flash Media Server is running on my PC and it&#8217;s connected to the Internet.</p>
<p>Here&#8217;s another of those lessons that I learned after hours of trying to figure out why my code wasn&#8217;t working. In this case my code just wasn&#8217;t dirty enough. :-)</p>
<p>What had happened was that I was trying to save an ArrayCollection of objects to a Remote SharedObject. And it just wouldn&#8217;t take. It worked fine if I tried to set the value of a String, or Number, but that wasn&#8217;t what I needed.</p>
<p>What was even more baffling was that when I debugged I could see that the RSO had stored the initial set of data. But I couldn&#8217;t make any changes and update the values.</p>
<p>Eventually I noticed this method for RSOs called <em>setDirty</em> &#8211; from the docs:</p>
<blockquote><p><strong>setDirty()</strong><br />
Indicates to the server that the value of a property in the shared object has  changed. This method marks properties as <em>dirty</em>, which means changed.</p>
<p>Call the <code>SharedObject.setProperty()</code> to create properties for a  shared object.</p>
<p>The <code>SharedObject.setProperty()</code> method implements  <code>setDirty()</code>. In most cases, such as when the value of a property is  a primitive type like String or Number, you can call <code>setProperty()</code> instead of calling <code>setDirty()</code>. However, when the value of a  property is an object that contains its own properties, call  <code>setDirty()</code> to indicate when a value within the object has changed.</p></blockquote>
<p>Essentially the Remote SharedObject can&#8217;t tell when a complex object has changed it&#8217;s value. So change the value and then calling <em>setDirty</em> is like saying, &#8220;Trust me, it&#8217;s changed.&#8221;</p>
<table border="0" cellspacing="0" cellpadding="0" width="300" align="right">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1245_RemoteSharedObjects_gettingDirty_post_2024531792"
			class="flashmovie"
			width="300"
			height="400">
	<param name="movie" value="/flex/1251_RemoteSharedObjects_gettingDirty/_1245_RemoteSharedObjects_gettingDirty_post.swf" />
	<param name="wmode" value="normal" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/flex/1251_RemoteSharedObjects_gettingDirty/_1245_RemoteSharedObjects_gettingDirty_post.swf"
			name="fm__1245_RemoteSharedObjects_gettingDirty_post_2024531792"
			width="300"
			height="400">
		<param name="wmode" value="normal" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="/flex/1251_RemoteSharedObjects_gettingDirty/srcview/index.html">view source</a></td>
</tr>
</tbody>
</table>
<p>Even with a primative type, like String or Number, if you set the value of an RSO to the value it already has then the Sync event won&#8217;t fire. Now that&#8217;s probably a good thing in most cases but there might be some cases in which you want to fire the Sync event regardless. In that case use <em>setDirty</em>.</p>
<p>In the example here you&#8217;ll notice that if you repeatedly click either of the top buttons it will only call the Sync event on the first click. Afterwards, even though you are calling the <em>setProperty() </em>method over and over the Sync doesn&#8217;t refire.</p>
<p>But the bottom buttons call the <em>setProperty() </em>and<em> setDirty()</em>. That forces the Sync to fire even if the value of the RSO hasn&#8217;t changed.</p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="dan@polygeek.com" /><input type="hidden" name="return" value="http://polygeek.com/thank-you-for-donating" /><input type="hidden" name="item_name" value="Nothing says thanks better than a few $$$. :) for Getting Dirty with Remote SharedObjects" /><input type="hidden" name="currency_code" value="USD" /><input type="hidden" name="amount" value="" /><input type="image" src="http://polygeek.com/wp-content/plugins/buy-me-beer/icon_beer.gif" align="left" alt="tip-jar" title="tip-jar" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=dan@polygeek.com&amp;currency_code=USD&amp;amount=&amp;return=http://polygeek.com/thank-you-for-donating&amp;item_name=Nothing+says+thanks+better+than+a+few+$$$.+:)+for+Getting+Dirty+with+Remote+SharedObjects" target="paypal"><SPAN STYLE="font-size: x-small">If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.</span></a></p><p align="left"><a class="tt" href="http://twitter.com/home/?status=Getting+Dirty+with+Remote+SharedObjects+http://bit.ly/5dBuLj" title="Post to Twitter"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-twitter-big1.png" alt="Post to Twitter" /></a> <a class="tt" href="http://delicious.com/post?url=http://polygeek.com/1251_flex_getting-dirty-with-remote-sharedobjects&amp;title=Getting+Dirty+with+Remote+SharedObjects" title="Post to Delicious"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-delicious-big1.png" alt="Post to Delicious" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://polygeek.com/1251_flex_getting-dirty-with-remote-sharedobjects&amp;t=Getting+Dirty+with+Remote+SharedObjects" title="Post to Facebook"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-facebook-big1.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://polygeek.com/1251_flex_getting-dirty-with-remote-sharedobjects&amp;title=Getting+Dirty+with+Remote+SharedObjects" title="Post to Reddit"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-reddit-big1.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://polygeek.com/1251_flex_getting-dirty-with-remote-sharedobjects&amp;title=Getting+Dirty+with+Remote+SharedObjects" title="Post to StumbleUpon"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-su-big1.png" alt="Post to StumbleUpon" /></a></p><p><a href="http://polygeek.com/1251_flex_getting-dirty-with-remote-sharedobjects" rel="bookmark">Getting Dirty with Remote SharedObjects</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on October 22, 2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1251_flex_getting-dirty-with-remote-sharedobjects/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Persistence of Remote SharedObjects</title>
		<link>http://polygeek.com/1108_flex_persistence-of-remote-sharedobjects</link>
		<comments>http://polygeek.com/1108_flex_persistence-of-remote-sharedobjects#comments</comments>
		<pubDate>Tue, 21 Oct 2008 17:00:46 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flash Media Server]]></category>
		<category><![CDATA[Remote SharedObjects]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1108</guid>
		<description><![CDATA[When creating a Remote SharedObject the third parameter that you pass to the getRemote method is a Boolean for persistence.  In my first example it was false so there was no actual file stored on the Flash Media Server. But if persistence = true then a file will be created in your Flash Media Server&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>When creating a Remote SharedObject the third parameter that you pass to the <em>getRemote</em> method is a Boolean for <em>persistence</em>.  In <a href="http://polygeek.com/1106_flex_experimenting-with-remote-sharedobjects">my first example</a> it was false so there was no actual file stored on the Flash Media Server. But if <em>persistence</em> = true then a file will be created in your Flash Media Server&#8217;s application folder and there it will stay. That&#8217;s handy for tracking data between user visits.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1108_RemoteSharedObject_Persistence_post_56131971"
			class="flashmovie"
			width="350"
			height="254">
	<param name="movie" value="/flex/1108_RemoteSharedObjects_persistence/_1108_RemoteSharedObject_Persistence_post.swf" />
	<param name="wmode" value="normal" />
	<param name="allowscriptaccess" value="always" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/flex/1108_RemoteSharedObjects_persistence/_1108_RemoteSharedObject_Persistence_post.swf"
			name="fm__1108_RemoteSharedObject_Persistence_post_56131971"
			width="350"
			height="254">
		<param name="wmode" value="normal" />
		<param name="allowscriptaccess" value="always" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="/flex/1108_RemoteSharedObjects_persistence/srcview/index.html">view source</a></td>
</tr>
</tbody>
</table>
<p>In this simple example here I&#8217;m storing two persistent Remote SharedObjects. The first Remote SharedObject is to keep track of the number of visitors that load the Flex app. Each time the app starts up and creates a connection to Flash Media Server it gets the data, which is just a number, and then adds one to it before updating the RSO. Pretty simple but there are a few nuances to consider.</p>
<p>One of them is that in order to keep the data current, so that if another user visits while you have it open you would like for it to increment your visitors count as well. So we have to keep listening to the SYNC event of the RSO. But when we update the RSO the first time it will cause fire the SYNC event again, causing it to update again, and again.</p>
<p>The easiest way I could think of to stop that is to keep track of which time the SYNC event is running. By setting a Boolean &#8211; <em>_isTotalSet</em> &#8211; equal to false and then after we update the <em>_totalCountRSO</em> setting it to true then we can use that within an if-statement to make sure that we keep getting updates to the SYNC event but only update the _totalCountRSO once.</p>
<p>The other RSO is a little more tricky. It tracks the current number of users. The problem is that when a user leaves the page, either by browsing to another page or closing the Tab/Window we need to know so that we can subtract one from the <em>_currentCountRSO.</em></p>
<p>To get that update we have to rely on the HTML container and ExternalInterface to get a notification. Something that isn&#8217;t particularly reliable. If the notification doesn&#8217;t arrive then the <em>_currentCountRSO</em> will slowely keep counting up every now and then. I haven&#8217;t come up with a solid solution as yet. I&#8217;m looking at using some server side script to occationally reset the <em>_currentCountRSO</em> to zero. That will come in a later update, when I get to that chapter. ;-)</p>
<p><strong>Adendummmm</strong><br />
The Javascript for removing 1 count from the _currentCountRSO isn&#8217;t working at all within the blog. It does work in stand alone pages with the app. I have <em>allowScriptAccess</em> set to <em>always</em>, the Javascript is embeded in the page template. Got me. Any ideas?</p>
<p>Actually, I just discovered that it does work on FireFox in my Ubuntu laptop. Whatever!</p>
<p>The <em>index.template.html</em> is included in the source code so you can see how all that works. Plus I threw in a comment here and there. It should be pretty easy to follow.</p>
<p>All you need to run this app yourself is Flash Media Server 3. If you need I have a <a href="http://polygeek.com/501_video-tutorial_video-tutorial-installing-flash-media-server-3">video tutorial that covers FMS installation and setup</a>.</p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="dan@polygeek.com" /><input type="hidden" name="return" value="http://polygeek.com/thank-you-for-donating" /><input type="hidden" name="item_name" value="Nothing says thanks better than a few $$$. :) for Persistence of Remote SharedObjects" /><input type="hidden" name="currency_code" value="USD" /><input type="hidden" name="amount" value="" /><input type="image" src="http://polygeek.com/wp-content/plugins/buy-me-beer/icon_beer.gif" align="left" alt="tip-jar" title="tip-jar" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=dan@polygeek.com&amp;currency_code=USD&amp;amount=&amp;return=http://polygeek.com/thank-you-for-donating&amp;item_name=Nothing+says+thanks+better+than+a+few+$$$.+:)+for+Persistence+of+Remote+SharedObjects" target="paypal"><SPAN STYLE="font-size: x-small">If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.</span></a></p><p align="left"><a class="tt" href="http://twitter.com/home/?status=Persistence+of+Remote+SharedObjects+http://bit.ly/50g3aC" title="Post to Twitter"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-twitter-big1.png" alt="Post to Twitter" /></a> <a class="tt" href="http://delicious.com/post?url=http://polygeek.com/1108_flex_persistence-of-remote-sharedobjects&amp;title=Persistence+of+Remote+SharedObjects" title="Post to Delicious"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-delicious-big1.png" alt="Post to Delicious" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://polygeek.com/1108_flex_persistence-of-remote-sharedobjects&amp;t=Persistence+of+Remote+SharedObjects" title="Post to Facebook"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-facebook-big1.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://polygeek.com/1108_flex_persistence-of-remote-sharedobjects&amp;title=Persistence+of+Remote+SharedObjects" title="Post to Reddit"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-reddit-big1.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://polygeek.com/1108_flex_persistence-of-remote-sharedobjects&amp;title=Persistence+of+Remote+SharedObjects" title="Post to StumbleUpon"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-su-big1.png" alt="Post to StumbleUpon" /></a></p><p><a href="http://polygeek.com/1108_flex_persistence-of-remote-sharedobjects" rel="bookmark">Persistence of Remote SharedObjects</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on October 21, 2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1108_flex_persistence-of-remote-sharedobjects/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Experimenting with Remote SharedObjects</title>
		<link>http://polygeek.com/1106_flex_experimenting-with-remote-sharedobjects</link>
		<comments>http://polygeek.com/1106_flex_experimenting-with-remote-sharedobjects#comments</comments>
		<pubDate>Mon, 20 Oct 2008 17:00:29 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flash Media Server]]></category>
		<category><![CDATA[Remote SharedObjects]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1106</guid>
		<description><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1106_RemoteSharedObjects_Accordion_post_405901604"
			class="flashmovie"
			width="250"
			height="400">
	<param name="movie" value="/flex/1106_RemoteSharedObjects_Accordion/_1106_RemoteSharedObjects_Accordion_post.swf" />
	<param name="wmode" value="normal" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/flex/1106_RemoteSharedObjects_Accordion/_1106_RemoteSharedObjects_Accordion_post.swf"
			name="fm__1106_RemoteSharedObjects_Accordion_post_405901604"
			width="250"
			height="400">
		<param name="wmode" value="normal" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object> view source It turns out that Flash Media Server 3 can do a lot more than just stream video. You can also use it for things like storing Remote SharedObjects. Which is really handy for creating all sorts of collaborative web applications. Remote SharedObjects are very similar to local [...]]]></description>
			<content:encoded><![CDATA[<table border="0" cellspacing="0" cellpadding="0" width="250" align="right">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1106_RemoteSharedObjects_Accordion_post_689123527"
			class="flashmovie"
			width="250"
			height="400">
	<param name="movie" value="/flex/1106_RemoteSharedObjects_Accordion/_1106_RemoteSharedObjects_Accordion_post.swf" />
	<param name="wmode" value="normal" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/flex/1106_RemoteSharedObjects_Accordion/_1106_RemoteSharedObjects_Accordion_post.swf"
			name="fm__1106_RemoteSharedObjects_Accordion_post_689123527"
			width="250"
			height="400">
		<param name="wmode" value="normal" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="/flex/1106_RemoteSharedObjects_Accordion/srcview/index.html">view source</a></td>
</tr>
</tbody>
</table>
<p>It turns out that Flash Media Server 3 can do a lot more than just stream video. You can also use it for things like storing Remote SharedObjects. Which is really handy for creating all sorts of collaborative web applications.</p>
<p>Remote SharedObjects are very similar to local SharedObjects. But the Remote version has one very, VERY, handy feature: when the data in a Remote SharedObject is changed it triggers an event to every instance of the SharedObject.</p>
<p>As an example, check out the Flex app to the right here with the Flex accordion. Have you noticed it changing automatically? If so that&#8217;s because someone else is viewing this page, right now, and they are navigating around in the accordion. If it&#8217;s not changing then maybe there&#8217;s no one else reading this post.  So try opening this page in a new Tab/Window. Now you can navigate in one Tab/Window and see it change in the other. Cool, eh?</p>
<p>Obviously this is a very rudimentary example but I wanted to keep it as simple as possible and not muck up the essential point here with a bunch of unnecessary code.</p>
<p>To experiment with this you&#8217;ll need Flash Media Server 3 running on your machine. If you don&#8217;t already then I have a <a href="http://polygeek.com/501_video-tutorial_video-tutorial-installing-flash-media-server-3">video tutorial that covers the installation and setup</a>. It&#8217;s very easy, when it works. When it doesn&#8217;t it&#8217;s a real pain in the rear exhaust port. :-)</p>
<p>Tip: Don&#8217;t change the value of a Remote SharedObject in the SYNC handler. Because that will cause it to fire again, and again, and, I think they call this an infinite loop. You don&#8217;t want that. :-)</p>
<p><strong>Addendummmmm</strong><br />
Initially this app wasn&#8217;t working on any PC except mine. After a few hours of pondering, and poking I finally happened upon the solution.</p>
<p>If you look at the source code you&#8217;ll see the following line in the init() method:</p>
<p><code>_nc.connect( "rtmp://localhost/FMS_Flex" );</code></p>
<p>Now the version that you&#8217;re actually loading here is slightly different because I added a little code to call to get the IP address from a database. Because I&#8217;m running this off my home PC and I don&#8217;t have a static IP address. So now when it changes all I&#8217;ll have to do is go update the DB and all my apps will work again.</p>
<p>Anyhow, the connection should actually look like this:</p>
<p><code>_nc.connect( "rtmp://localhost:1935/FMS_Flex" );</code></p>
<p>or in the actually implimentation here</p>
<p><code>_nc.connect( "rtmp://" + ip + ":1935/FMS_Flex" );</code></p>
<p>Where the variable &#8220;ip&#8221; is retrieved from the DB.</p>
<p>Now this does seem a little odd to me because I could stream video off my FMS server without specifying the port. Do you know why? &#8217;cause I don&#8217;t. :-)</p>
<p>Special thanks to <a href="http://cisnky.com/">cisnky</a> for the suggestion that it was port related. Because I didn&#8217;t think it was at first.</p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="dan@polygeek.com" /><input type="hidden" name="return" value="http://polygeek.com/thank-you-for-donating" /><input type="hidden" name="item_name" value="Nothing says thanks better than a few $$$. :) for Experimenting with Remote SharedObjects" /><input type="hidden" name="currency_code" value="USD" /><input type="hidden" name="amount" value="" /><input type="image" src="http://polygeek.com/wp-content/plugins/buy-me-beer/icon_beer.gif" align="left" alt="tip-jar" title="tip-jar" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=dan@polygeek.com&amp;currency_code=USD&amp;amount=&amp;return=http://polygeek.com/thank-you-for-donating&amp;item_name=Nothing+says+thanks+better+than+a+few+$$$.+:)+for+Experimenting+with+Remote+SharedObjects" target="paypal"><SPAN STYLE="font-size: x-small">If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.</span></a></p><p align="left"><a class="tt" href="http://twitter.com/home/?status=Experimenting+with+Remote+SharedObjects+http://bit.ly/5HYexP" title="Post to Twitter"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-twitter-big1.png" alt="Post to Twitter" /></a> <a class="tt" href="http://delicious.com/post?url=http://polygeek.com/1106_flex_experimenting-with-remote-sharedobjects&amp;title=Experimenting+with+Remote+SharedObjects" title="Post to Delicious"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-delicious-big1.png" alt="Post to Delicious" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://polygeek.com/1106_flex_experimenting-with-remote-sharedobjects&amp;t=Experimenting+with+Remote+SharedObjects" title="Post to Facebook"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-facebook-big1.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://polygeek.com/1106_flex_experimenting-with-remote-sharedobjects&amp;title=Experimenting+with+Remote+SharedObjects" title="Post to Reddit"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-reddit-big1.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://polygeek.com/1106_flex_experimenting-with-remote-sharedobjects&amp;title=Experimenting+with+Remote+SharedObjects" title="Post to StumbleUpon"><img class="nothumb" src="http://polygeek.com/wp-content/plugins/tweet-this/icons/tt-su-big1.png" alt="Post to StumbleUpon" /></a></p><p><a href="http://polygeek.com/1106_flex_experimenting-with-remote-sharedobjects" rel="bookmark">Experimenting with Remote SharedObjects</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on October 20, 2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1106_flex_experimenting-with-remote-sharedobjects/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
