<?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>*drawlogic &#187; STATE</title>
	<atom:link href="http://drawlogic.com/category/state/feed/" rel="self" type="application/rss+xml" />
	<link>http://drawlogic.com</link>
	<description>interactive and game development technologies for the web - flash, flex, unity3d, silverlight, javascript</description>
	<lastBuildDate>Thu, 17 May 2012 13:12:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>HOWTO: SharedObjects for Local Storage AS3</title>
		<link>http://drawlogic.com/2008/01/10/howto-sharedobjects-for-local-storage-as3/</link>
		<comments>http://drawlogic.com/2008/01/10/howto-sharedobjects-for-local-storage-as3/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 10:21:41 +0000</pubDate>
		<dc:creator>drawk</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ACTIONSCRIPT]]></category>
		<category><![CDATA[ACTIONSCRIPT3]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[APPLICATIONS]]></category>
		<category><![CDATA[ARCHITECT]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CODE]]></category>
		<category><![CDATA[DATA]]></category>
		<category><![CDATA[GAMEDEV]]></category>
		<category><![CDATA[GAMES]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[OPEN SOURCE]]></category>
		<category><![CDATA[PROGRAMMING]]></category>
		<category><![CDATA[SNIPPETS]]></category>
		<category><![CDATA[STATE]]></category>
		<category><![CDATA[TECHNOLOGY]]></category>
		<category><![CDATA[TUTORIAL]]></category>

		<guid isPermaLink="false">http://drawlogic.com/2008/01/10/howto-sharedobjects-for-local-storage-as3/</guid>
		<description><![CDATA[Using SharedObjects in Flash is very simple. Flash has SharedObjects that have been in the player since Flash6 when the introduction of Flash Communication Server which is now Flash Media Server which is releasing version 3 soon (also remote SharedObjects in Red5 is an open source RTMP media server that is based on Flash Media [...]]]></description>
			<content:encoded><![CDATA[<p>Using SharedObjects in Flash is very simple.  Flash has SharedObjects that have been in the player since Flash6 when the introduction of Flash Communication Server which is now Flash Media Server which is releasing version 3 soon (also remote SharedObjects in <a href="http://osflash.org/red5" target="_blank">Red5</a> is an open source RTMP media server that is based on Flash Media Server).  So we can thank this release for SharedObjects, Camera objects, Audio, lots of the NetConnections, protocol enhancements and many other things. However to keep the tips simple we will just touch on the local usage and post a series of posts on these objects.</p>
<p><b>SharedObjects locally and remote have changed the way offline is thought about and are the backbone of many offline systems and prototypes.</b>  They have been influential in moving storage locally to remote in a lightweight AMF0 or AMF3 format.</p>
<p><b>SharedObject is in the <a href="http://livedocs.adobe.com/flex/2/langref/flash/net/package-detail.html">flash.net</a> namespace in AS3.</b></p>
<p><b>Here we show how to use the local version of a SharedObject to store data in the most simple form.  </b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #660066;">SharedObject</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> so<span style="color: #339933;">:</span>SharedObject <span style="color: #339933;">=</span> SharedObject.<span style="color: #660066;">getLocal</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;userData&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">data</span>.<span style="color: #660066;">username</span><span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;user1377&quot;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">data</span>.<span style="color: #660066;">pwdhash</span><span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;[hash] or pwd&quot;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// writes changes to disk</span></pre></div></div>

<p>You can see this is extremely simple to store data.<b></b><b>Here we show how to use the local version of a SharedObject to retrieve data in the most simple form.  </b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #660066;">SharedObject</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> so<span style="color: #339933;">:</span>SharedObject <span style="color: #339933;">=</span> SharedObject.<span style="color: #660066;">getLocal</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;userData&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> username<span style="color: #339933;">:</span>String <span style="color: #339933;">=</span> so.<span style="color: #660066;">data</span>.<span style="color: #660066;">username</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> pwdhash<span style="color: #339933;">:</span>String <span style="color: #339933;">=</span> so.<span style="color: #660066;">data</span>.<span style="color: #660066;">pwdhash</span><span style="color: #339933;">;</span></pre></div></div>

<p>That is it!  In the most basic form SharedObjects are more simple than cookies and also are quite nice living outside the bounds of the cookies folder.  If a user deletes all cookies it will not delete the SharedObjects.  To delete SharedObjects you need to roght click on the Flash player, go to Settings and delete the objects there.<b></b><b>You can store any type of data Flash supports from objects to numbers to strings in the SharedObject data.  </b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #660066;">SharedObject</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> so<span style="color: #339933;">:</span>SharedObject <span style="color: #339933;">=</span> SharedObject.<span style="color: #660066;">getLocal</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;userData&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">data</span>.<span style="color: #660066;">username</span><span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;user1377&quot;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">data</span>.<span style="color: #660066;">uid</span><span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Number<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1337</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> obj<span style="color: #339933;">:</span>Object <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Object<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
obj.<span style="color: #660066;">prop</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;value&quot;</span><span style="color: #339933;">;</span>
so.<span style="color: #660066;">data</span>.<span style="color: #660066;">userobj</span><span style="color: #339933;">=</span> obj<span style="color: #339933;">;</span>
so.<span style="color: #660066;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// writes changes to disk</span></pre></div></div>

<p>For large applications SharedObjects local are great because users can have their SharedObject space set to a high amount of space or unlmited for large offline type apps or more complex apps stored in a state object. It gets interesting when you pass this to the server in AMF or extremely compact AMF3 format to a remote stored object, via remoting, Shared Object events or any way you want to.We will be posting more on remote shared objects and some of the other tools such as Camera and Streams for AS3 over the coming weeks and deeper into the Sync Events for remote and local SOs.<b><a href="http://www.sephiroth.it/python/solreader.php" target="_blank">Sephiroth has a great Python tool to peer into the SOs on disk</a></b>.</p>
<blockquote><p>The first version of SharedObject Reader was written in <a href="http://www.python.org/">python 2.2</a>.<br />
This new version is written in <b>C#</b> (C Sharp) as it&#8217;s now part of <b><a href="http://www.flashdevelop.org/">FlashDevelop</a></b> editor.</p></blockquote>
<p>Red5 also does this as well as many AMF kits.</p>
<p><b>Sync Events for SharedObject (as they change they launch a sync event) </b></p>
<p><span class="label">Event object type: </span><a href="http://livedocs.adobe.com/flex/2/langref/flash/events/SyncEvent.html" target="_blank"><code>flash.events.SyncEvent</code></a><br />
<span class="label">SyncEvent.type property = </span><a href="http://livedocs.adobe.com/flex/2/langref/flash/events/SyncEvent.html#SYNC" target="_blank"><code>flash.events.SyncEvent.SYNC</code></a></p>
<p><b>Read more at adobe docs:</b></p>
<p><a href="http://livedocs.adobe.com/flex/2/langref/flash/net/SharedObject.html#includeExamplesSummary" target="_blank">flash.net.SharedObject</a></p>
<p><b>Sample from AS3 docs showing usage</b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">package</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">display</span>.<span style="color: #660066;">Sprite</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #660066;">MouseEvent</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">events</span>.<span style="color: #660066;">NetStatusEvent</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #660066;">SharedObject</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">net</span>.<span style="color: #660066;">SharedObjectFlushStatus</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">text</span>.<span style="color: #660066;">TextField</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">text</span>.<span style="color: #660066;">TextFieldAutoSize</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">import</span> flash.<span style="color: #660066;">text</span>.<span style="color: #660066;">TextFieldType</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">class</span> SharedObjectExample <span style="color: #003366; font-weight: bold;">extends</span> Sprite <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> mySo<span style="color: #339933;">:</span>SharedObject<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">public</span> <span style="color: #003366; font-weight: bold;">function</span> SharedObjectExample<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            buildUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">CLICK</span><span style="color: #339933;">,</span> saveValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>MouseEvent.<span style="color: #660066;">CLICK</span><span style="color: #339933;">,</span> clearValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            mySo <span style="color: #339933;">=</span> SharedObject.<span style="color: #660066;">getLocal</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;application-name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SharedObject loaded...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;loaded value: &quot;</span> <span style="color: #339933;">+</span> mySo.<span style="color: #660066;">data</span>.<span style="color: #660066;">savedValue</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
         <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> saveValue<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>MouseEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;saving value...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            mySo.<span style="color: #660066;">data</span>.<span style="color: #660066;">savedValue</span> <span style="color: #339933;">=</span> input.<span style="color: #660066;">text</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">var</span> flushStatus<span style="color: #339933;">:</span>String <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                flushStatus <span style="color: #339933;">=</span> mySo.<span style="color: #660066;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>error<span style="color: #339933;">:</span>Error<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Error...Could not write SharedObject to disk<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>flushStatus <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>flushStatus<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">case</span> SharedObjectFlushStatus.<span style="color: #660066;">PENDING</span><span style="color: #339933;">:</span>
                        output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Requesting permission to save object...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        mySo.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span>NetStatusEvent.<span style="color: #660066;">NET_STATUS</span><span style="color: #339933;">,</span> onFlushStatus<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">case</span> SharedObjectFlushStatus.<span style="color: #660066;">FLUSHED</span><span style="color: #339933;">:</span>
                        output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Value flushed to disk.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> clearValue<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>MouseEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Cleared saved value...Reload SWF and the value should be <span style="color: #000099; font-weight: bold;">\&quot;</span>undefined<span style="color: #000099; font-weight: bold;">\&quot;</span>.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">delete</span> mySo.<span style="color: #660066;">data</span>.<span style="color: #660066;">savedValue</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> onFlushStatus<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>NetStatusEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;User closed permission dialog...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #660066;">info</span>.<span style="color: #660066;">code</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;SharedObject.Flush.Success&quot;</span><span style="color: #339933;">:</span>
                    output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;User granted permission -- value saved.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;SharedObject.Flush.Failed&quot;</span><span style="color: #339933;">:</span>
                    output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;User denied permission -- value not saved.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            output.<span style="color: #660066;">appendText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            mySo.<span style="color: #660066;">removeEventListener</span><span style="color: #009900;">&#40;</span>NetStatusEvent.<span style="color: #660066;">NET_STATUS</span><span style="color: #339933;">,</span> onFlushStatus<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// UI elements</span>
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> inputLbl<span style="color: #339933;">:</span>TextField<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> input<span style="color: #339933;">:</span>TextField<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> output<span style="color: #339933;">:</span>TextField<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> saveBtn<span style="color: #339933;">:</span>Sprite<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">var</span> clearBtn<span style="color: #339933;">:</span>Sprite<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">private</span> <span style="color: #003366; font-weight: bold;">function</span> buildUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// input label</span>
            inputLbl <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            addChild<span style="color: #009900;">&#40;</span>inputLbl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            inputLbl.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            inputLbl.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            inputLbl.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Value to save:&quot;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// input TextField</span>
            input <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            addChild<span style="color: #009900;">&#40;</span>input<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">80</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">border</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">background</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            input.<span style="color: #660066;">type</span> <span style="color: #339933;">=</span> TextFieldType.<span style="color: #660066;">INPUT</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// output TextField</span>
            output <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            addChild<span style="color: #009900;">&#40;</span>output<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">35</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">250</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">250</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">multiline</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">wordWrap</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">border</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            output.<span style="color: #660066;">background</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// Save button</span>
            saveBtn <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Sprite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            addChild<span style="color: #009900;">&#40;</span>saveBtn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">190</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">useHandCursor</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">lineStyle</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">beginFill</span><span style="color: #009900;">&#40;</span>0xcccccc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">drawRoundRect</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> saveLbl<span style="color: #339933;">:</span>TextField <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveBtn.<span style="color: #660066;">addChild</span><span style="color: #009900;">&#40;</span>saveLbl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            saveLbl.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Save&quot;</span><span style="color: #339933;">;</span>
            saveLbl.<span style="color: #660066;">selectable</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// Clear button</span>
            clearBtn <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Sprite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            addChild<span style="color: #009900;">&#40;</span>clearBtn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">x</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">230</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">y</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">useHandCursor</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">lineStyle</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">beginFill</span><span style="color: #009900;">&#40;</span>0xcccccc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">graphics</span>.<span style="color: #660066;">drawRoundRect</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> clearLbl<span style="color: #339933;">:</span>TextField <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> TextField<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearBtn.<span style="color: #660066;">addChild</span><span style="color: #009900;">&#40;</span>clearLbl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            clearLbl.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Clear&quot;</span><span style="color: #339933;">;</span>
            clearLbl.<span style="color: #660066;">selectable</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://drawlogic.com/2008/01/10/howto-sharedobjects-for-local-storage-as3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

