<?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>Jayc Santos &#187; Actionscript 3</title>
	<atom:link href="http://jaycsantos.com/category/flash/actionscript3/feed/" rel="self" type="application/rss+xml" />
	<link>http://jaycsantos.com</link>
	<description>Games, Development, Blog</description>
	<lastBuildDate>Sun, 15 Nov 2009 17:13:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Trick to Using SharedObject</title>
		<link>http://jaycsantos.com/flash/the-trick-to-using-sharedobject/</link>
		<comments>http://jaycsantos.com/flash/the-trick-to-using-sharedobject/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 12:30:18 +0000</pubDate>
		<dc:creator>Jayc Santos</dc:creator>
				<category><![CDATA[Actionscript 2]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as2]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[code bits]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jaycsantos.com/?p=470</guid>
		<description><![CDATA[Having a SAVE feature in a project/game is one of the common things that could lead users to be more attracted and increase replay value for potentially recovering what was done in a previous visit. Using the SharedObject class in actionscript project/games is sometimes a requirement or at least a need, may it be AS1 [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_472" class="wp-caption alignleft" style="width: 210px"><img class="size-full wp-image-472" title="SharedObjects" src="http://jaycsantos.com/uploads/2009/04/sharedobject.gif" alt="Shared Objects ~= Browser Cookies" width="200" height="90" /><p class="wp-caption-text"> </p></div>
<p>Having a <em>SAVE</em> feature in a project/game is one of the common things that could lead users to be more attracted and increase replay value for potentially recovering what was done in a previous visit. Using the SharedObject class in actionscript project/games is sometimes a requirement or at least a need, may it be AS1 (FP6), 2 or 3. It can be used to store valuable data like progress, settings, statistics, achievements and a lot more without dedicating storage on the server. Basically, SO or shared objects are like the browser cookies for flash, it is used to store some amount of data on the user machine, therefore it also has some limitations on its use (for security purposes really).</p>
<p>By reading the documentations or the livedocs, either for <a rel="external nofollow" href="http://livedocs.adobe.com/flash/9.0/main/00002118.html" target="_blank">AS2</a> or <a rel="external nofollow" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html" target="_blank">AS3</a> (it&#8217;s really the same), you might have a gut start of what key points to remember.</p>
<ul>
<li>created shared objects can only be stored/retrieved on the same domain</li>
<li>shared objects cannot be shared across domains, meaning a shared objects from &#8220;examplesite.com&#8221; cannot read shared objects created by another domain &#8220;mywebsite.com&#8221;</li>
<li>users can disallow local storage per domain or opt-out globaly, then the object would not be saved locally</li>
<li>data size to be stored is limited by which the user sets it (none, 10kb, 100kb, 1mb, 10mb, unlimited), although a dialog box can request an increase in storage if what is set is exceeded</li>
<li>if the user sets a limit smaller than the shared object, the shared object would be deleted</li>
<li>shared objects are stored on the user&#8217;s local machine not on the server, something shared over another machine cannot be accessed by another machine</li>
</ul>
<p>The most essential part when using SharedObject is the <code>SharedObject.getLocal()</code> method, which is what we will be discussing more through out. Basically, AS1/2 and AS3 syntax haven&#8217;t really changed (although a few more rules were imposed in as3).</p>
<blockquote class="white"><p><strong><span style="color: #000080;">getLocal</span></strong>(name:<span style="color: #000080;">String</span>, localPath:<span style="color: #000080;">String </span>= null, secure:<span style="color: #000080;">Boolean </span>= false):<span style="color: #000080;">SharedObject</span><br />
[static] Returns a reference to a locally persistent shared object that is only available to the current client.</p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> mySo:<span style="color: #0066CC;">SharedObject</span> = <span style="color: #0066CC;">SharedObject</span>.<span style="color: #0066CC;">getLocal</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'mySaveName'</span>, localPath, secure <span style="color: #66cc66;">&#41;</span>;
mySo.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">thingtoSave</span> = myVariable; <span style="color: #808080; font-style: italic;">// your variables</span>
mySo.<span style="color: #0066CC;">flush</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// stores data into disk</span></pre></div></div>

<hr />
<h3>Avoiding Known Issues</h3>
<p>It might seem that using shared objects could be the simplest when you are only storing a couple of variables and objects like statistics or even could be the more complex when saving a game progress/state together with the players preferences. The bigger the system, more likely, the more complex your variables/objects are (same for games), and this is where possible issues during saving/loading/handling the shared objects.<br />
<span id="more-470"></span></p>
<p>Some common things to remember when using shared objects with your games:</p>
<ol>
<li><a href="#tip1">Don&#8217;t use direct reference to objects and use the game&#8217;s data only not the actual game objects</a>.</li>
<li><a href="#tip2">Use a localPath param on the <code>getLocal()</code> method</a>.</li>
<li><a href="#tip3">Taking advantage of unique names for your shared object name</a>.</li>
<li><a href="#tip4">Prompt and request for shared object size limit increase when your game needs it</a>.</li>
</ol>
<blockquote><p>While I only have these that I can explain, you are free to share more if you have one or more. We can discuss and make the lives of other actionscript writers a little better.</p></blockquote>
<p><br id="tip1" /></p>
<hr />
<h3>Don&#8217;t use direct reference to objects and use the game&#8217;s data only not the actual game objects.</h3>
<p>Why do I say this? Basically it is fine to store various data types such as objects and arrays on SO (shared objects), same goes for strings, numbers (int/uint), booleans and bytearray (as3). If you store references to local game objects on your shared objects, one way or another, your in for a later problem.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> mySo:<span style="color: #0066CC;">SharedObject</span> = <span style="color: #0066CC;">SharedObject</span>.<span style="color: #0066CC;">getLocal</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;mySaveName&quot;</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// world.gameObject contains further objects like settings, player, etc</span>
mySo.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">gamedata</span> = world.<span style="color: #006600;">gameObject</span>;
mySo.<span style="color: #0066CC;">flush</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// --</span></pre></div></div>

<p>When you do something like the above, instead of storing the needed values only, you are referencing the local game object (w/c also contains references to other local game objects) in which Flash defines this as a copy of the local object but is really just a reference. Any change through out the game values/data would <strong>update</strong> the local object (which the shared object references) and Flash Player would write that into the shared object file when <code>flush()</code> is called or as soon as the shared object session ends &#8211; that is then swf file is closed.</p>
<p>The worst case here is that when you clear, reset or even delete your local game objects, the shared object which references to it will be affected and updated (as session has ended).</p>
<p>Also, even if don&#8217;t experience the possibility of issues when you do the above there, a problem might still arise when you load the shared object in later time. This case might not be so common but is possible to experience if loading the shared object is sloppily made. You can have inconsistent object references where the object contained within loaded shared object is conflicting, a duplicate, or not referencing the correct object.</p>
<p>A better and safest way of using shared objects (something like):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">mySo.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">gamedata</span> = <span style="color: #66cc66;">&#123;</span>
  player:<span style="color: #66cc66;">&#123;</span>
    score: world.<span style="color: #006600;">gameObject</span>.<span style="color: #006600;">player</span>.<span style="color: #006600;">score</span>,
    health: world.<span style="color: #006600;">gameObject</span>.<span style="color: #006600;">player</span>.<span style="color: #006600;">health</span>,
    currentLevel: <span style="color: #66cc66;">&lt;</span>code<span style="color: #66cc66;">&gt;</span>world.<span style="color: #006600;">gameObject</span>.<span style="color: #006600;">player</span>.<span style="color: #006600;">currentLevel</span>
  <span style="color: #66cc66;">&#125;</span>,
  settings:<span style="color: #66cc66;">&#123;</span>
    mute: world.<span style="color: #006600;">gameObject</span>.<span style="color: #006600;">settings</span>.<span style="color: #006600;">mute</span>,
    <span style="color: #0066CC;">quality</span>: world.<span style="color: #006600;">gameObject</span>.<span style="color: #006600;">settings</span>.<span style="color: #0066CC;">quality</span>,
    particles: world.<span style="color: #006600;">gameObject</span>.<span style="color: #006600;">settings</span>.<span style="color: #006600;">particles</span>,
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* well this is just a shortcut on containing them into objects,
 * but the point here is that score, health, currentLevel, etc
 * are all basic data types like number/int/uint, string, bool, etc&lt;/code&gt;</span></pre></div></div>

<p>Now you see that we store each valuable data only. We now transfer only the value of the variable not it&#8217;s reference. So while it&#8217;s fine to use objects and arrays on your shared objects, keeping be wary of how you do it, be careful.</p>
<p>You probably wouldn&#8217;t want to directly store instances of display objects, bitmapdata, functions, etc on share objects.<br />
<br id="tip2" /></p>
<hr />
<h3>Use a localPath param on the <code>getLocal()</code> method</h3>
<p>While passing the localPath parameter upon calling<code> getLocal()</code> is optional, although I would have to recommend using it by this time. In the case where you are building an independent system, prototypes, does not consider expansion/addons and will never be a part of a larger system, you can probably opt-out the localPath and never mind it.</p>
<p>So whats the issue of using and not using the localPath? By default, if you leave localPath by it&#8217;s default (null), it would use the the full path of the swf file (w/c includes the swf file itself) to store your shared objects.</p>
<blockquote class="white"><p>#SharedObjects/<span style="color: #808000;">&lt;random code&gt;</span>/<span style="color: #808000;">&lt;domain&gt;</span>/<span style="color: #808000;">&lt;path&gt;</span>/<span style="color: #808000;">&lt;swf filename&gt;</span>.swf/<span style="color: #808000;">&lt;object name&gt;</span>.sol</p></blockquote>
<blockquote>
<ul>
<li><em>Windows XP and Vista:</em>
<ul>
<li>For Web sites: %APPDATA%\Macromedia\Flash Player\#SharedObjects\&lt;random code&gt;\&lt;domain&gt;\&lt;path&gt;\&lt;object name&gt;.sol</li>
<li>For AIR Applications, %APPDATA%\&lt;AIR Application Reverse Domain Name&gt;\Local Store\#SharedObjects\&lt;flash filename&gt;.swf\&lt;object name&gt;.sol</li>
</ul>
</li>
</ul>
<ul>
<li><em>Mac OS X:</em>
<ul>
<li>For Web sites, ~/Library/Preferences/Macromedia/Flash Player/#SharedObjects/&lt;random code&gt;/&lt;domain&gt;/&lt;path from webserver&gt;/&lt;object name&gt;.sol</li>
<li>For AIR Applications, ~/Library/Preferences/&lt;AIR Application Name&gt;/Local Store/#SharedObjects/&lt;flash filename&gt;.swf/&lt;object name&gt;.sol</li>
</ul>
</li>
<li><em>Linux/Unix:</em>
<ul>
<li>~/.macromedia/Flash_Player/#SharedObjects/&lt;random id&gt;/&lt;domain&gt;/&lt;path&gt;/&lt;flash filename&gt;.swf/&lt;object name&gt;.sol</li>
</ul>
</li>
</ul>
<p style="padding-left: 30px;"><em>-taken from <a rel="external nofollow" href="http://en.wikipedia.org/wiki/Local_Shared_Object#File_locations" target="_blank">wiki</a></em></p>
</blockquote>
<p>For example, I have a swf  at <code>http://example.com/games/uploads/supergame.swf</code>, and when it creates a shared object (<code>SharedObject.getLocal("supergameData");</code>), the SO can be found at <code>#SharedObjects/</code><span style="color: #808000;">&lt;random code&gt;</span><code>/example.com/games/uploads/supergame.swf/supergameData.sol</code>.</p>
<p>While it works well and fine without the localPath parameter, there are certain sites/APIs/services that change the game&#8217;s file name by using their automated uploads, feeds, etc as the file name is used in the path. When the developer tries to upload a bug fixed build (v1.0.1), the swf might have another file name hence a problem appears where the previous build&#8217;s (v1.0.0) shared object won&#8217;t be accessible from the new build due to security reasons.</p>
<p>Although your shared object would be secured against any another swf so it can&#8217;t read it, by setting a localPath parameter like &#8220;/games&#8221; or simply &#8220;/&#8221;, the shared object can now be read by another swf file within the same domain. Using &#8220;/games&#8221; would make the SO accessible for any swf within the game directory, while having &#8220;/&#8221; would make it accessible from any swf within the domain.</p>
<p>Again from the same example but using <code>SharedObject.getLocal("supergameData","/");</code>, makes the SO at <code>#SharedObjects/</code><span style="color: #808000;">&lt;random code&gt;</span><code>/example.com/supergameData.sol</code>. This would make it not dependant on the swf&#8217;s file name.</p>
<blockquote><p><strong>Note</strong>: If you set a localPath in which the path doesn&#8217;t physically exists as a (sub) directory of the domain the shared object won&#8217;t be stored. Luckily with AS3 you&#8217;ll be prompted with an Error #2134 when the SharedObject can&#8217;t be created, but for AS2, you have to be well aware of this.</p></blockquote>
<p><br id="tip3" /></p>
<hr />
<h3>Taking advantage of unique names for your shared object name</h3>
<p>This is one is something that I have just learned through experimentation and will soon incorporate on my next projects. While setting the localPath parameter to &#8220;/&#8221; makes the SO accessible to other swfs, there is also a risk that your SO name might be the same with another swf. We wouldn&#8217;t want another swf to mess up or overwrite our SO file just because it both uses general and/or generic SO names like &#8220;<em>saveData</em>&#8221; or &#8220;<em>gameData</em>&#8220;.</p>
<p><strong>The ultimate tip</strong>: Since the SO names allow certain special characters like / (slash), we take advantage of that! Together with the localPath &#8220;/&#8221;, what I recommend is do a standard setup for your SO names something like:</p>
<blockquote class="white"><p><span style="color: #808000;">&lt;company/developer name&gt;</span>/<span style="color: #808000;">&lt;game name&gt;</span>/<span style="color: #808000;">&lt;data name&gt;</span></p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> mySo:<span style="color: #0066CC;">SharedObject</span> = <span style="color: #0066CC;">SharedObject</span>.<span style="color: #0066CC;">getLocal</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;jaycsantos/neolithic/preferences&quot;</span>, <span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// -- and/or something else like</span>
<span style="color: #000000; font-weight: bold;">var</span> mySo:<span style="color: #0066CC;">SharedObject</span> = <span style="color: #0066CC;">SharedObject</span>.<span style="color: #0066CC;">getLocal</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;jaycsantos/neolithic/gameData1&quot;</span>, <span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// --</span></pre></div></div>

<p>&#8230;will store your SO at something like: <code>#SharedObjects/</code><span style="color: #808000;">&lt;random code&gt;</span><code>/</code><span style="color: #808000;">&lt;domain&gt;</span><code>/#jaycsantos/neolithic/gameData.sol</code></p>
<blockquote><p>Although I still have to confirm this with Mac OS and Linux machines. Drop me a line if you find it working with those.</p></blockquote>
<p>Now ain&#8217;t that a little more organized than having all SO on the &#8220;/&#8221; of the domain!<br />
<br id="tip4" /></p>
<hr />
<h3>Prompt and request for shared object size limit increase when your game needs it</h3>
<div id="attachment_471" class="wp-caption aligncenter" style="width: 240px"><img class="size-full wp-image-471" title="Local Storage" src="http://jaycsantos.com/uploads/2009/04/localstorage.gif" alt="Local Storage" width="230" height="150" /><p class="wp-caption-text"> </p></div>
<p>There are cases when your shared object has a lot of data in it and it could exceed the default 100kb limit of a user. If this happens, it may cause your shared objects to be written but not read. I have read quite a few times where issues of reading/writing of share objects were resolved by prompting a request to increase local storage limit. This is where the <code>flush() </code>method takes it stand.</p>
<blockquote class="white"><p>Immediately writes a locally persistent  shared object to a local file.<br />
<span style="color: #888888;"><em>AS3</em></span><span style="color: #000080;"><strong><br />
flush</strong></span>(<code>minDiskSpace</code>:<span style="color: #000080;">int</span> = 0):<span style="color: #000080;">String</span></p>
<div style="padding-left: 30px;"><code>minDiskSpace</code><code>:</code><span style="color: #000080;">int</span> (default = <code>0</code>) —  The minimum disk space, in bytes, that must be allotted for this object.</div>
<p><span style="color: #888888;"><em>AS2</em></span><br />
<span style="color: #000080;"><strong><span class="signatureLink">flush</span></strong></span><code>([minDiskSpace:</code><span style="color: #000080;">Number</span><code>])</code>:Object</p>
<div style="padding-left: 30px;"><code>minDiskSpace:</code><span style="color: #000080;">Number</span> [optional] &#8211; An integer specifying  the number of bytes that must be allotted for this object. The default value is  0.</div>
</blockquote>
<p>With AS3, the <code>flush()</code> method basically does the same thing as with AS2 including their parameters, the only difference made was their return values. AS3 returns a string constant but AS2 returns an object; still their purpose is the same, only the data types have changed.</p>
<div class="wp_syntax">
<div><span style="color: #888888;"><em>AS3</em></span>:<br />
<strong>Returns</strong></p>
<div style="padding-left: 30px;"><span style="color: #000080;">String </span>— Either of the following values:</div>
<ul>
<li><code>SharedObjectFlushStatus.PENDING</code>: The user has permitted local information storage for objects from this domain, but the amount of space allotted is not sufficient to store the object. Flash Player prompts the user to allow more space. To allow space for the shared object to grow when it is saved, thus avoiding a SharedObjectFlushStatus.PENDING return value, pass a value for minDiskSpace.</li>
<li><code>SharedObjectFlushStatus.FLUSHED</code>: The shared object has been successfully written to a file on the local disk.</li>
</ul>
<p><em><span style="color: #888888;">AS2</span></em>:<br />
<strong>Returns</strong></p>
<div style="padding-left: 30px;"><span style="color: #000080;">Object </span>- A Boolean value: <code>true </code>or <code>false</code>; or a string value of &#8220;<code>pending</code>&#8220;, as described in the following list:</div>
<ul>
<li>If the user has permitted local information storage for objects from this domain, and the amount of space allotted is sufficient to store the object, this method returns true. (If you have passed a value for <code>minimumDiskSpace</code>, the amount of space allotted must be at least equal to that value for <code>true </code>to be returned).</li>
<li>If the user has permitted local information storage for objects from this domain, but the amount of space allotted is not sufficient to store the object, this method returns &#8220;<code>pending</code>&#8220;.</li>
<li>If the user has permanently denied local information storage for objects from this domain, or if Flash cannot save the object for any reason, this method returns <code>false</code>.</li>
</ul>
<div style="padding-left: 30px;"><em>- taken from livedocs (<a rel="external nofollow" href="http://livedocs.adobe.com/flash/9.0/main/00002121.html" target="_blank">as2</a> &amp; <a rel="external nofollow" href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html#flush()" target="_blank">as3</a>)<br />
</em></div>
</div>
</div>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> mySo:<span style="color: #0066CC;">SharedObject</span> = <span style="color: #0066CC;">SharedObject</span>.<span style="color: #0066CC;">getLocal</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'mySaveName'</span>, localPath, secure  <span style="color: #66cc66;">&#41;</span>;
mySo.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">thingtoSave</span> = myVariable; <span style="color: #808080; font-style: italic;">// your variables</span>
<span style="color: #808080; font-style: italic;">/* stores data into disk and require 10kb of min space
 * if the allocated disk space for local storage is
 * less than 10bk which most probaly be 1kb, then it
 * would prompt a dialog box requesting for an increase
 */</span>
<span style="color: #000000; font-weight: bold;">var</span> fushResult:<span style="color: #0066CC;">Object</span> = mySo.<span style="color: #0066CC;">flush</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10000</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> fushResult <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>So saying simply, if you know your game&#8217;s shared object will be greater than a few kbs, you should consider using <code>flush(minDiskSpace)</code> with as your expect maximum size for your data. Why maximum? &#8211; think of it as your allowance. Now don&#8217;t even consider 2mb or more as an allowance if it&#8217;ll never even reach it, play your game at it&#8217;s fullest and see what is the size of the shared object using the <code>getSize()</code> method (as2) and the property <code>size</code> (as3) then add around 5-10% of it&#8217;s size for an allowance.</p>
<h3>Conclusion</h3>
<p>After all I have read about using SharedObject is as simple as it could be, in reality it can be a whole lot more than spinning circles for all of what you would need. Well yes, storing a string and recovering it is a piece of icing but storing a complete game state/progress is a new kind of cake to bake. Basically what I have written here are tips and suggestions that I have experienced and with what I have experimented. Either it be accurate or I know not, using SharedObjects has its own work around and is not as simple as most people have said like building a chair, while yes it is not the most complicated but it could be a big question mark on the head for someone new or not familiar to its purpose. I might even consider making a SaveManager or the like but that would be when I get to it. Well, that&#8217;s it, this one is quite long but I know it&#8217;ll help!</p>
<h3>Other Keywords</h3>
<ul>
<li>Working with Flash Actionscript Shared objects.</li>
<li>Issues and techniques with Flash Actionscript shared objects.</li>
<li>Saving data with action script using shared objects.</li>
<li>Actionscript tips and tricks, shared objects.</li>
<li>Shared object help, actionscript 2 &amp; actionscript 3.</li>
<li>Flash actionscript saving &amp; loading locally.</li>
<li>Flash Actionscript proper way of use when Shared Object does not work.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jaycsantos.com/flash/the-trick-to-using-sharedobject/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Do you know ActionScript? AS3 Stage</title>
		<link>http://jaycsantos.com/flash/do-you-know-actionscript-as3-stage/</link>
		<comments>http://jaycsantos.com/flash/do-you-know-actionscript-as3-stage/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 07:38:47 +0000</pubDate>
		<dc:creator>Jayc Santos</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[code bits]]></category>

		<guid isPermaLink="false">http://jaycsantos.com/?p=366</guid>
		<description><![CDATA[Before, the Stage class in AS2 is treated as a class whose properties are all static, but with AS3 the new and better Stage class is now a display object. Both making the stage class the main drawing area and where flash content is shown. Basically, just think of it as a practical stage, all [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_369" class="wp-caption alignleft" style="width: 270px"><img class="size-full wp-image-369" title="stage" src="http://jaycsantos.com/uploads/2009/03/stage.jpg" alt="Stage" width="260" height="170" /><p class="wp-caption-text">Where are my display objects?</p></div>
<p>Before, the Stage class in AS2 is treated as a class whose properties are all static, but with AS3 the new and better Stage class is now a display object. Both making the stage class the main drawing area and where flash content is shown. Basically, just think of it as a practical stage, all actors and props are all objects on display and those who are backstage are objects which are simply not included in the stage yet.</p>
<p>The Stage is a singleton class whereas there can only be one instance of it (imagine watching a play where there are 2 or more stages, its just impossible). Even if you add multiple instances of display objects to the display list, the stage property of each display object still refers to the same Stage object (that goes for loaded SWF files too).</p>
<blockquote><p>Did you know that the stage is not globally accessible &#8211; you can&#8217;t call it or reference it from anywhere (unless manually referenced in a variable of course). The simplest way to do so is to use the <code>stage</code> property from any of your display objects which were added to the display list.</p></blockquote>
<p>Yes, you heard it right from &#8220;any&#8221; display object, but take note, only if it is already added to the display list. It doesn&#8217;t matter if your display object is a child of another display object or how far the display heirarchy it is, as long as it is included in the display list.</p>
<blockquote><p>Don&#8217;t confuse yourself with &#8220;Stage&#8221; (with capital &#8220;S&#8221;) and &#8220;stage&#8221; (with small caps). &#8220;Stage&#8221; refers to the class flash.display.Stage and &#8220;stage&#8221; is it&#8217;s instance.</p>
<p>Just remember, from a common coding convention: classes begin with capital letters and variables don&#8217;t.</p></blockquote>
<p>If the display object is removed or not yet added from the display list the stage property is just set to null.</p>
<p><span id="more-366"></span></p>
<hr />
<h4>Example:</h4>
<p>Create a Square.as. The doStuff function just tries to see if the stage is available or not from its own scope.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
    <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Graphics</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Square extends <span style="color: #004993;">Sprite</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Square<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #009900;">// just some drawing</span>
            <span style="color: #004993;">graphics</span>.<span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">2</span>, 0x666666 <span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawCircle</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">0</span>, <span style="color: #000000; font-weight:bold;">48</span> <span style="color: #000000;">&#41;</span>;
            <span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">100</span>;
            <span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">100</span>;
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> doStuff<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">stage</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000;">&#41;</span> <span style="color: #009900;">// if stage is available</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">'I see the stage! '</span><span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">stage</span> <span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #009900;">// stage is not available</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">'I am not on stage... :( '</span> <span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Now create MyStage.as and a new Flash File (actioscript 3.0) then set MyStage as your Document class (just on your properties panel).</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">MovieClip</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MyStage extends <span style="color: #004993;">MovieClip</span>
    <span style="color: #000000;">&#123;</span>
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MyStage<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
&nbsp;
            <span style="color: #6699cc; font-weight: bold;">var</span> square<span style="color: #000000; font-weight: bold;">:</span>Square = <span style="color: #0033ff; font-weight: bold;">new</span> Square<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// instanciate a Square</span>
            square.doStuff<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
            <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> square <span style="color: #000000;">&#41;</span>; <span style="color: #009900;">// add the square instance into display list</span>
            square.doStuff<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>When you test your movie the output panel should display something like:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">I am not on stage... :(
I see the stage! [object Stage]</pre></div></div>

<hr />
<h4>Neat Trick: code snippet</h4>
<p>So based on this you can have a neat little trick to determine if your display objects are on stage and added to the display list.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> isDisplayed<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">Boolean</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">stage</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span></pre></div></div>

<p>I hope you understand a little bit more with using display objects and the stage from what I have shared.</p>
<hr />
<h3>Other Keywords</h3>
<ul>
<li>Working with Actionscript 3 Stage.</li>
<li>Knowing Flash Actionscript 3 Stage.</li>
<li>Stage &amp; stage difference in actionscript 3.</li>
<li>Proper use of Flash Actionscript 3 Stage.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jaycsantos.com/flash/do-you-know-actionscript-as3-stage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Experiment: How to determine if allowNetworking parameter is enabled</title>
		<link>http://jaycsantos.com/flash/experiment-how-to-determine-if-allownetworking-parameter-is-enabled/</link>
		<comments>http://jaycsantos.com/flash/experiment-how-to-determine-if-allownetworking-parameter-is-enabled/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 17:06:42 +0000</pubDate>
		<dc:creator>Jayc Santos</dc:creator>
				<category><![CDATA[Actionscript 2]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://jaycsantos.com/?p=276</guid>
		<description><![CDATA[I&#8217;ve been fond of experimenting on things and so this time with what I do and work on most. I&#8217;ll try to make some research and test based on what I have made. These posts won&#8217;t be recognized as 100% accurate and correct on all situations although I aim to be at the most. See [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been fond of experimenting on things and so this time with what I do and work on most. I&#8217;ll try to make some research and test based on what I have made. These posts won&#8217;t be recognized as 100% accurate and correct on all situations although I aim to be at the most. See <a href="http://jaycsantos.com/disclaimer/" target="_blank">disclaimer </a>before implementing any theories and/or statements described in. So let me start with an quite old issue with disabling external links upon embedding an swf in a web page.</p>
<p>Since flash player 9, site owners were allowed to take use of the additional security. You can control a SWF file&#8217;s access to network functionality by setting the <code>allowNetworking</code> parameter in the <code>&lt;object&gt;</code> and <code>&lt;embed&gt;</code> tags in the HTML page that contains the SWF content. It can be included by having:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">object</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000066;">data</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sample.swf&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;application/x-shockwave-flash&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;id&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sampleswf&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;allowNetworking&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;internal&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;src&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sample.swf&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sampleswf&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">object</span>&gt;</span></pre></div></div>

<p>See your help file about this or view the livedocs (<a href="http://livedocs.adobe.com/flash/9.0/main/00001079.html" target="_blank">as2</a> or <a href="http://livedocs.adobe.com/flash/9.0/main/00000351.html" target="_blank">as3</a>) discussing this added security.  Basically if this ever happens to a flash game, the developer and/or sponsor are neglected of having click backs to their own sites/portals, which is not a good thing. So I made a little research and test if actionscript can determine if  <code>allowNetworking</code> was enabled or not. This test will try to determine if external links are allowed, not exactly return the value of the <code>allowNetworking</code> parameter.<span id="more-276"></span> I made a <a href="http://jaycsantos.com/uploads/2008/10/allowNetworking-test/allowNetworking-test.html" target="_blank">sample page here</a> having 2 swfs (as2 &amp; as3) embedded in different ways: using the basic embed-object tags, AC_RunActiveContent.js and swfobject class. As said in that page, the swfs on the left uses <code>allowNetworking</code> set to &#8220;<code>internal</code>&#8221; so it should say &#8220;External links disabled&#8221; and the swfs on the right doesn&#8217;t so it should say &#8220;External links ok&#8221;. Then try clicking on the links on each swf and determine if the message displayed respectively complies (either <em>disabled</em> or <em>OK</em>), if so then it pass if not then a fail.  And these are the results I had (all with winXP):</p>
<table class="tabol" style="text-align:center; font-size:0.95em;" border="0">
<tbody>
<tr class="b">
<td rowspan="2"></td>
<td style="text-align: center;" colspan="2">basic Embed</td>
<td colspan="2">AC_RunActiveContent.js</td>
<td colspan="2">swfobject class</td>
</tr>
<tr class="b">
<td>AS2</td>
<td>AS3</td>
<td>AS2</td>
<td>AS3</td>
<td>AS2</td>
<td>AS3</td>
</tr>
<tr>
<td class="b">Firefox 3.03</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
</tr>
<tr>
<td class="b">Opera 9.5</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
</tr>
<tr>
<td class="b">Safari 3.1.2</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
</tr>
<tr>
<td class="b">Chrome 0.2.149.30</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
</tr>
<tr>
<td class="b">IE 7.0.5730</td>
<td style="color:red;">fail</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
</tr>
<tr>
<td class="b">IE 6</td>
<td style="color:red;">fail</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
</tr>
<tr>
<td class="b">IE 5.5</td>
<td style="color:red;">fail</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
<td>pass</td>
</tr>
</tbody>
</table>
<p><strong>In conclusion</strong>: I wasn&#8217;t successful with AS2, and to mention that the AS2 code that I used is just a trick and not legally proven in anyway. Also if you try to make a trap-like-function with your game/project/swf you should also be aware that opening external links are disabled with standalone flash players by default (which I think implements allowNetworking = &#8220;internal&#8221; with the standalone player&#8217;s sandbox). So the when the AS3 sample is ran using the standalone player you can catch the error number which will be error #0.  <strong>Note</strong>: If you are using another browser which I haven&#8217;t tested or another OS, you are very much encouraged to comment out if my <a href="http://jaycsantos.com/uploads/2008/10/allowNetworking-test/allowNetworking-test.html" target="_blank">sample page</a> worked properly or not with what you have.</p>
<hr />So how did I made those results? Here are the codes that I used:</p>
<blockquote><p>Please read the <a href="http://jaycsantos.com/disclaimer/" target="_blank">DISCLAIMER</a> first before you do anything with what you&#8217;ll see and learn.</p></blockquote>
<p><strong>Actionscript 2:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">external</span>.<span style="color: #006600;">ExternalInterface</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> allowNetworking;
<span style="color: #000000; font-weight: bold;">var</span> str:<span style="color: #0066CC;">String</span>;
&nbsp;
<span style="color: #0066CC;">try</span><span style="color: #66cc66;">&#123;</span>
	allowNetworking = ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;
	str = allowNetworking +<span style="color: #ff0000;">''</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> str == <span style="color: #ff0000;">'null'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Error&quot;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">_root</span>.<span style="color: #006600;">test</span>.<span style="color: #0066CC;">htmlText</span> = <span style="color: #ff0000;">'external links OKn&quot;'</span>+ str +<span style="color: #ff0000;">'&quot;'</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span><span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span> $e <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">_root</span>.<span style="color: #006600;">test</span>.<span style="color: #0066CC;">htmlText</span> = <span style="color: #ff0000;">'external links DISABLEDn &quot;'</span>+ str +<span style="color: #ff0000;">'&quot;'</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
btn.<span style="color: #0066CC;">onRelease</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">getURL</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://jaycsantos.com&quot;</span>,<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>In AS2, if the <code>ExternalInterface.call()</code> failed it doesn&#8217;t throw an error unlike in AS3 so I have to make some workarounds with AS2 to get a return value from any possible function call and <code>ExternalInterface.call()</code> is my only chance. <code>ExternalInterface.call(null)</code> was expected to return a <code>null</code> value when <code>allowNetworking</code> is set to either &#8220;<code>internal</code>&#8221; or &#8220;<code>none</code>&#8221; and was supposed to be <code>undefined</code> when not. It was almost a passing code trick but IE has failed once again making the whole AS2 test a failure.</p>
<p><strong>Actionscript 3:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.external</span>.<span style="color: #004993;">ExternalInterface</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> allowNetworking<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>;
&nbsp;
<span style="color: #0033ff; font-weight: bold;">try</span><span style="color: #000000;">&#123;</span>
	allowNetworking = <span style="color: #004993;">ExternalInterface</span>.<span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #004993;">test</span>.<span style="color: #004993;">htmlText</span> = <span style="color: #990000;">'external links OK'</span>;
<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">catch</span><span style="color: #000000;">&#40;</span> $e<span style="color: #000000; font-weight: bold;">:*</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">test</span>.<span style="color: #004993;">htmlText</span> = <span style="color: #990000;">'external links DISABLEDn err #'</span><span style="color: #000000; font-weight: bold;">+</span> $e.<span style="color: #004993;">errorID</span> <span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">''</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> mouseClickHandler<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #004993;">navigateToURL</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://jaycsantos.com/&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
btn.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>, mouseClickHandler<span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>Practically I used <code>ExternalInterface.call(null)</code> instead of trying to instantiate <code>URLRequest</code> because if it succeeds it would open up an external link and might just be blocked by a popup-blocker since the code is ran without user interaction. Unlike AS2, it will simply throw in an error when the network method is restricted.</p>
<blockquote><p>Please read the <a href="http://jaycsantos.com/disclaimer/" target="_blank">DISCLAIMER</a> first before you do anything with what you&#8217;ve seen and learned.</p></blockquote>
<p>I would not recommend using any of this in a professional project or until further tests are made. But it somehow shows logic that it should work especially with the AS3 code, so <strong>use at your own risk</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaycsantos.com/flash/experiment-how-to-determine-if-allownetworking-parameter-is-enabled/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->