<?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>manewc &#187; Data Sharing</title>
	<atom:link href="http://manewc.com/category/actionscript-data/feed/" rel="self" type="application/rss+xml" />
	<link>http://manewc.com</link>
	<description>iPhone, Flash, Flex, AIR, &#38; Web Development</description>
	<lastBuildDate>Sat, 31 Oct 2009 16:47:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>[AS 3] Shared Object between Multiple SWF Files</title>
		<link>http://manewc.com/2008/04/02/as-3-shared-object-between-multiple-swf-files/</link>
		<comments>http://manewc.com/2008/04/02/as-3-shared-object-between-multiple-swf-files/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 18:10:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Data Sharing]]></category>

		<guid isPermaLink="false">http://manewc.com/2008/04/02/as-3-shared-object-between-multiple-swf-files/</guid>
		<description><![CDATA[I have been working on my .mp3 player that requires two .swf movies, one to play the music and another to control it (like a remote control to your stereo). This implementation is required so as the user navigates from one page to another the music will not be interrupted. The good thing is that [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on my .mp3 player that requires two .swf movies, one to play the music and another to control it (like a remote control to your stereo). This implementation is required so as the user navigates from one page to another the music will not be interrupted. The good thing is that the SharedObject can be retrieved by other movies if you use a line of code such as:</p>
<p>_so = SharedObject.getLocal(&#8221;SharedObjectID&#8221;,&#8221;/&#8221;);</p>
<p>One thing to be careful of is to not allow the ability of other .swf movies (other than your own) to retrieve/edit/delete this object.</p>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/04/02/as-3-shared-object-between-multiple-swf-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[AS 3] Flash Cookies with the Local Shared Object</title>
		<link>http://manewc.com/2008/01/30/as-3-flash-cookies-with-the-shared-object/</link>
		<comments>http://manewc.com/2008/01/30/as-3-flash-cookies-with-the-shared-object/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 18:38:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Data Sharing]]></category>

		<guid isPermaLink="false">http://manewc.com/2008/01/30/as-3-flash-cookies-with-the-shared-object/</guid>
		<description><![CDATA[Since the sharedObject method in Actionscript has proved itself to be very useful in the past (like my .mp3 player to play across multiple .html pages), I wondered how it was implemented in Actionscript 3. I found some nice code over at adobe and made some slight modifications so you wouldn&#8217;t have to refresh your [...]]]></description>
			<content:encoded><![CDATA[<p>Since the sharedObject method in Actionscript has proved itself to be very useful in the past (like my <a href="http://manewc.com/2008/01/02/flash-mp3-player-across-multiple-html-files/">.mp3 player to play across multiple .html pages</a>), I wondered how it was implemented in Actionscript 3. I found some nice code over at adobe and made some slight modifications so you wouldn&#8217;t have to refresh your movie. To interact, just type in some text and then hit the save button to save this snippet on your machine. Once saved, that snippet will display in the movie below until you clear it out.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ObjectSharing_1819738450"
			class="flashmovie"
			width="550"
			height="350">
	<param name="movie" value="/projects/flash/SharedObject/ObjectSharing.swf" />
	<param name="bgcolor" value="#000000" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/SharedObject/ObjectSharing.swf"
			name="fm_ObjectSharing_1819738450"
			width="550"
			height="350">
		<param name="bgcolor" value="#000000" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here is my document class ObjectSharing.as</p>
<pre name="code" class="c-sharp">
package
{
	/*
	Original Source
	http://livedocs.adobe.com/flex/2/langref/flash/net/SharedObject.html#includeExamplesSummary
	*/

	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.NetStatusEvent;
	import flash.net.SharedObject;
	import flash.net.SharedObjectFlushStatus;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;

	public class ObjectSharing extends Sprite {  

		private var mySo:SharedObject;

		public function ObjectSharing()
		{
			buildUI();
			saveBtn.addEventListener(MouseEvent.CLICK, saveValue);
			clearBtn.addEventListener(MouseEvent.CLICK, clearValue);

			mySo = SharedObject.getLocal("application-name");
			output.appendText("SharedObject loaded...\n");
			output.appendText("loaded value: " + mySo.data.savedValue + "\n\n");

			if ( mySo.data.savedValue )
			{
				soStatus.text = mySo.data.savedValue;
			}
			else
			{
				soStatus.text = "undefined";
			}

    	}  

		private function saveValue(event:MouseEvent):void {
        	output.appendText("saving value...\n");
        	mySo.data.savedValue = input.text;

			var flushStatus:String = null;

			try
			{
            	flushStatus = mySo.flush(10000);
        	} catch (error:Error) {
            	output.appendText("Error...Could not write SharedObject to disk\n");
			}

        	if (flushStatus != null)
			{
            	switch (flushStatus)
				{
                	case SharedObjectFlushStatus.PENDING:
                    	output.appendText("Requesting permission to save object...\n");
                    	mySo.addEventListener(NetStatusEvent.NET_STATUS, onFlushStatus);
                    	break;
					case SharedObjectFlushStatus.FLUSHED:
                    	output.appendText("Value flushed to disk.\n");
                    	break;
				}
			}
        	output.appendText("\n");

			soStatus.text = mySo.data.savedValue;
		}

		private function clearValue(event:MouseEvent):void {
        	output.appendText("Cleared saved value...Reload SWF and the value should be \"undefined\".\n\n");
        	delete mySo.data.savedValue;

			soStatus.text = "[deleted] value is: " + mySo.data.savedValue;
    	}

		private function onFlushStatus(event:NetStatusEvent):void {
			output.appendText("User closed permission dialog...\n");
			switch (event.info.code)
			{
            	case "SharedObject.Flush.Success":
                	output.appendText("User granted permission -- value saved.\n");
                	break;
            	case "SharedObject.Flush.Failed":
                	output.appendText("User denied permission -- value not saved.\n");
                	break;
        	}  

			output.appendText("\n");

        	mySo.removeEventListener(NetStatusEvent.NET_STATUS, onFlushStatus);
		}  

    	// UI elements
    	private var inputLbl:TextField;
    	private var input:TextField;
    	private var output:TextField;
		private var soStatus:TextField;
		private var soStatusLbl:TextField;
   	 	private var saveBtn:Sprite;
    	private var clearBtn:Sprite;

    	private function buildUI():void
		{
			// White Text Formatting
			var whiteFormat:TextFormat = new TextFormat();
			whiteFormat.font = "Arial";
			whiteFormat.color = 0xffffff;
            whiteFormat.size = 10;
            whiteFormat.underline = false;

			// Black Text Formatting
			var blackFormat:TextFormat = new TextFormat();
			blackFormat.font = "Arial";
			blackFormat.color = 0x000000;
            blackFormat.size = 12;
            blackFormat.underline = false;

			// Small Black Text Formatting
			var smallBlackFormat:TextFormat = new TextFormat();
			smallBlackFormat.font = "Arial";
			smallBlackFormat.color = 0x000000;
            smallBlackFormat.size = 10;
            smallBlackFormat.underline = false;

			// New Shared Object Name
			var soFormat:TextFormat = new TextFormat();
			soFormat.font = "Arial";
			soFormat.color = 0x336699;
            soFormat.size = 12;
            soFormat.underline = false;

			// New Output Shared Object
			var soOutFormat:TextFormat = new TextFormat();
			soOutFormat.font = "Arial";
			soOutFormat.color = 0x009900;
            soOutFormat.size = 14;
            soOutFormat.underline = false;

        	// input label
        	inputLbl = new TextField();
			inputLbl.defaultTextFormat = whiteFormat;
        	addChild(inputLbl);
        	inputLbl.x = 10;
        	inputLbl.y = 10;
        	inputLbl.text = "Value to save:";

        	// input TextField
       		input = new TextField();
			input.defaultTextFormat = soFormat;
        	addChild(input);
        	input.x = 80;
        	input.y = 10;
        	input.width = 100;
        	input.height = 20;
        	input.border = true;
        	input.background = true;
        	input.type = TextFieldType.INPUT;

        	// output TextField
        	output = new TextField();
			output.defaultTextFormat = smallBlackFormat;
        	addChild(output);
        	output.x = 10;
        	output.y = 35;
            output.width = 250;
            output.height = 250;
            output.multiline = true;
            output.wordWrap = true;
            output.border = true;
            output.background = true;

			// SharedObject Status Field
			soStatus = new TextField();
			soStatus.defaultTextFormat = soOutFormat;
			addChild(soStatus);
			soStatus.x = 300;
        	soStatus.y = 35;
            soStatus.width = 200;
            soStatus.height = 30;
            soStatus.multiline = true;
            soStatus.wordWrap = true;
            soStatus.border = true;
            soStatus.background = true;

			soStatusLbl = new TextField();
			soStatusLbl.defaultTextFormat = whiteFormat;
			addChild(soStatusLbl);
			soStatusLbl.x = 300;
			soStatusLbl.y = 15;
			soStatusLbl.width = 250;
			soStatusLbl.height = 20;
			soStatusLbl.text = "Current Value of Shared Object:";
			soStatusLbl.selectable = false;

            // Save button
            saveBtn = new Sprite();
            addChild(saveBtn);
            saveBtn.x = 190;
            saveBtn.y = 10;
            saveBtn.useHandCursor = true;
            saveBtn.graphics.lineStyle(1);
            saveBtn.graphics.beginFill(0xcccccc);
            saveBtn.graphics.drawRoundRect(0, 0, 30, 20, 5, 5);
            var saveLbl:TextField = new TextField();
			saveLbl.defaultTextFormat = smallBlackFormat;
            saveBtn.addChild(saveLbl);
            saveLbl.text = "Save";
            saveLbl.selectable = false;

            // Clear button
            clearBtn = new Sprite();
            addChild(clearBtn);
            clearBtn.x = 230;
            clearBtn.y = 10;
            clearBtn.useHandCursor = true;
            clearBtn.graphics.lineStyle(1);
            clearBtn.graphics.beginFill(0xcccccc);
            clearBtn.graphics.drawRoundRect(0, 0, 30, 20, 5, 5);
            var clearLbl:TextField = new TextField();
			clearLbl.defaultTextFormat = smallBlackFormat;
            clearBtn.addChild(clearLbl);
            clearLbl.text = "Clear";
            clearLbl.selectable = false;
        }
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/01/30/as-3-flash-cookies-with-the-shared-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
