<?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>Ian Serlin &#187; Javascript</title>
	<atom:link href="http://ianserlin.com/index.php/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://ianserlin.com</link>
	<description>identifying pain points and creating chaos since 1984</description>
	<lastBuildDate>Fri, 08 Jan 2010 00:18:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Why you don&#8217;t skip adding curly braces on if statements in Javascript</title>
		<link>http://ianserlin.com/index.php/2010/01/05/why-you-dont-skip-adding-curly-braces-on-if-statements-in-javascript/</link>
		<comments>http://ianserlin.com/index.php/2010/01/05/why-you-dont-skip-adding-curly-braces-on-if-statements-in-javascript/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 16:24:11 +0000</pubDate>
		<dc:creator>Ian Serlin</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://ianserlin.com/?p=175</guid>
		<description><![CDATA[Don&#8217;t skimp on the curly braces wrapping if statements or other one-liner code blocks in Javascript because minifying/packing that Javascript can lead to avoidable and hard to track down errors, especially in IE which surprisingly cares a lot.
I&#8217;m super tired of seeing this bad practice and having it waste my time. You&#8217;re just lazy and [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t skimp on the curly braces wrapping if statements or other one-liner code blocks in Javascript because minifying/packing that Javascript can lead to avoidable and hard to track down errors, especially in IE which surprisingly cares a lot.</p>
<p>I&#8217;m super tired of seeing this bad practice and having it waste my time. You&#8217;re just lazy and that&#8217;s the worst kind of optimization.</p>
]]></content:encoded>
			<wfw:commentRss>http://ianserlin.com/index.php/2010/01/05/why-you-dont-skip-adding-curly-braces-on-if-statements-in-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding Facebook / Twitter / MySpace / Digg / Reddit / Bitly share functionality to your ActionScript 3/Flex application</title>
		<link>http://ianserlin.com/index.php/2009/12/18/adding-facebook-twitter-myspace-digg-reddit-bitly-share-functionality-to-your-actionscript-3flex-application/</link>
		<comments>http://ianserlin.com/index.php/2009/12/18/adding-facebook-twitter-myspace-digg-reddit-bitly-share-functionality-to-your-actionscript-3flex-application/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 10:23:11 +0000</pubDate>
		<dc:creator>Ian Serlin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Social networking]]></category>
		<category><![CDATA[bitly]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[myspace]]></category>
		<category><![CDATA[reddit]]></category>
		<category><![CDATA[share]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://ianserlin.com/?p=94</guid>
		<description><![CDATA[I&#8217;m not sure that I need to write anything about the importance of including social sharing tools in any project destined for more than a few people to use, but in case you think I do, here goes:  
If you make something that peoples reputations could benefit from being associated with and that thing [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not sure that I need to write anything about the importance of including social sharing tools in any project destined for more than a few people to use, but in case you think I do, here goes:  </p>
<p>If you make something that peoples reputations could benefit from being associated with and that thing is easy to share, people will share it&#8230; and more people will use it.
</p>
<h2>Problem</h2>
<p>There are many different social sharing APIs and you&#8217;d like to integrate some of these into your Flash/Flex project. Unfortunately, wrangling everything together isn&#8217;t as easy as it is in Javascript as long as tools like <a href="http://sharethis.com" target="_blank">ShareThis</a> and <a href="http://addthis.com" target="_blank">AddThis</a> continue to treat Flash apps as second class citizens.</p>
<h2>Solution</h2>
<p>The Share class let&#8217;s you initialize the title, description and custom tweet text associated with your content and then easily launch the share pages for Twitter, Facebook, MySpace, Digg and Reddit pre-populated with your specified text. As an added bonus, when you initialize the Share class it will contact <a href="http://bit.ly" target="_blank" title="Shorten, Share and track your links">bitly</a> to create a bitly url you can use for the current page your swf is embedded on.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.errors</span>.<span style="color: #004993;">IllegalOperationError</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">HTTPStatusEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">IOErrorEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">SecurityErrorEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">URLLoader</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">URLRequest</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">navigateToURL</span>;
	<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: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Share <span style="color: #000000;">&#123;</span> 
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> static const BITLY_USERNAME<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> 	= <span style="color: #990000;">&quot;&quot;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> static const BITLY_API_KEY<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>	= <span style="color: #990000;">&quot;&quot;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> title<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> 		= <span style="color: #990000;">&quot;&quot;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">description</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> 	= <span style="color: #990000;">&quot;&quot;</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> tweet_text<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>	= <span style="color: #990000;">&quot;&quot;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> bitlyURL<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _window_location<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>;
&nbsp;
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * The Singleton instance of the ShareManager to use when accessing properties and methods of the ShareManager.
		 */</span>		
		<span style="color: #0033ff; font-weight: bold;">public</span> static const instance<span style="color: #000000; font-weight: bold;">:</span>Share = <span style="color: #0033ff; font-weight: bold;">new</span> Share<span style="color: #000000;">&#40;</span> ShareSingletonLock <span style="color: #000000;">&#41;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Share<span style="color: #000000;">&#40;</span> <span style="color: #004993;">lock</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Class</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;">lock</span> <span style="color: #000000; font-weight: bold;">!</span>= ShareSingletonLock <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">IllegalOperationError</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;ShareManager is a Singleton, please use the static instance method instead.&quot;</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: #000000;">&#123;</span>
				_window_location = <span style="color: #004993;">ExternalInterface</span>.<span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;function () { return window.location.href.toString().toLowerCase(); }&quot;</span> <span style="color: #000000;">&#41;</span>;
				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> _window_location <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #990000;">&quot;&quot;</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
					<span style="color: #0033ff; font-weight: bold;">try</span><span style="color: #000000;">&#123;</span>
						getBitlyURL<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</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: #004993;">Error</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
						<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;ShareManager::Constructor &gt; error getting bitly url: &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> getBitlyURL<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</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>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span> title<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>, <span style="color: #004993;">description</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>, tweet_text<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</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: #0033ff; font-weight: bold;">this</span>.title			= title;
			<span style="color: #0033ff; font-weight: bold;">this</span>.<span style="color: #004993;">description</span>	= <span style="color: #004993;">description</span>;
			<span style="color: #0033ff; font-weight: bold;">this</span>.tweet_text		= tweet_text;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> getBitlyURL<span style="color: #000000;">&#40;</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: #6699cc; font-weight: bold;">var</span> bitly_api<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>	= <span style="color: #990000;">&quot;http://api.bit.ly/shorten?version=2.0.1&amp;longUrl=&quot;</span>;
			bitly_api 				<span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> _window_location <span style="color: #000000;">&#41;</span>;
			bitly_api 				<span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;login=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> BITLY_USERNAME;
			bitly_api 				<span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;apiKey=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> BITLY_API_KEY;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLLoader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">loader</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>, handleBitlyComplete <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">loader</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">HTTPStatusEvent</span>.<span style="color: #004993;">HTTP_STATUS</span>, handleBitlyStatus <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">loader</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">IOErrorEvent</span>.<span style="color: #004993;">IO_ERROR</span>, handleBitlyError <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">loader</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">SecurityErrorEvent</span>.<span style="color: #004993;">SECURITY_ERROR</span>, handleBitlyError <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">loader</span>.<span style="color: #004993;">load</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> bitly_api <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> handleBitlyComplete<span style="color: #000000;">&#40;</span> e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</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;">trace</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">'BITLY url load complete: '</span> <span style="color: #000000; font-weight: bold;">+</span> e <span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLLoader</span> = e.<span style="color: #004993;">target</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">URLLoader</span>;
			<span style="color: #0033ff; font-weight: bold;">try</span><span style="color: #000000;">&#123;</span>
				<span style="color: #6699cc; font-weight: bold;">var</span> response<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = <span style="color: #004993;">ExternalInterface</span>.<span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;function(){return &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span> <span style="color: #004993;">loader</span>.<span style="color: #004993;">data</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">String</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;}&quot;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> response.statusCode == <span style="color: #990000;">&quot;OK&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> response.results<span style="color: #000000;">&#91;</span> _window_location <span style="color: #000000;">&#93;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> response.results<span style="color: #000000;">&#91;</span> _window_location <span style="color: #000000;">&#93;</span>.errorCode == <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
					bitlyURL = response.results<span style="color: #000000;">&#91;</span> _window_location<span style="color: #000000;">&#93;</span>.shortUrl;
					<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">'Set BITLY url to: '</span> <span style="color: #000000; font-weight: bold;">+</span> bitlyURL <span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</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: #004993;">Error</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;Error decoding BITLY response (&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">loader</span>.<span style="color: #004993;">data</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;): &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> e <span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> handleBitlyStatus<span style="color: #000000;">&#40;</span> e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">HTTPStatusEvent</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;">trace</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">'BITLY status: '</span> <span style="color: #000000; font-weight: bold;">+</span> e <span style="color: #000000;">&#41;</span>;	
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> handleBitlyError<span style="color: #000000;">&#40;</span> e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</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;">trace</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">'Getting BITLY url failed with error: '</span> <span style="color: #000000; font-weight: bold;">+</span> e <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> redditURL<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #990000;">'http://www.reddit.com/submit?url='</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> _window_location <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;&amp;title=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> title <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> openReddit<span style="color: #000000;">&#40;</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> redditURL <span style="color: #000000;">&#41;</span>, <span style="color: #990000;">'_blank'</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> diggURL<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">url</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;http://digg.com/submit?url=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> _window_location <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;title=&quot;</span>    <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> title <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;bodytext=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">description</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;media=video&quot;</span>;
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">url</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> openDigg<span style="color: #000000;">&#40;</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> diggURL <span style="color: #000000;">&#41;</span>, <span style="color: #990000;">'_blank'</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> twitterURL<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> url_for_tweet<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>  	= bitlyURL <span style="color: #000000; font-weight: bold;">?</span> bitlyURL <span style="color: #000000; font-weight: bold;">:</span> _window_location;
			<span style="color: #6699cc; font-weight: bold;">var</span> twitter_status<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> 	= <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> tweet_text <span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #990000;">&quot;http://twitter.com/home/?status=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> twitter_status;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> openTwitter<span style="color: #000000;">&#40;</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> twitterURL <span style="color: #000000;">&#41;</span>, <span style="color: #990000;">'_blank'</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> mySpaceURL<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">url</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;http://www.myspace.com/index.cfm?fuseaction=postto&quot;</span>;
			<span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;t=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> title <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;c=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">description</span> <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;u=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> _window_location <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;r=close&quot;</span>;
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">url</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> openMySpace<span style="color: #000000;">&#40;</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> mySpaceURL <span style="color: #000000;">&#41;</span>, <span style="color: #990000;">'_blank'</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> facebookURL<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">url</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;http://www.facebook.com/share.php?src=bm&amp;v=4&amp;i=1254383639&quot;</span>;
			<span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;u=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> _window_location <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">url</span> <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #990000;">&quot;&amp;t=&quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">encodeURIComponent</span><span style="color: #000000;">&#40;</span> title <span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">url</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> openFacebook<span style="color: #000000;">&#40;</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> facebookURL <span style="color: #000000;">&#41;</span>, <span style="color: #990000;">'_blank'</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>
&nbsp;
<span style="color: #9900cc; font-weight: bold;">class</span> ShareSingletonLock <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>If you&#8217;ve created your own sharing API or you improve the above write it up and let me know in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://ianserlin.com/index.php/2009/12/18/adding-facebook-twitter-myspace-digg-reddit-bitly-share-functionality-to-your-actionscript-3flex-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making your ActionScript 3/Flex project work correctly in both development and production</title>
		<link>http://ianserlin.com/index.php/2009/12/02/making-your-actionscript-3flex-project-work-correctly-in-both-development-and-production/</link>
		<comments>http://ianserlin.com/index.php/2009/12/02/making-your-actionscript-3flex-project-work-correctly-in-both-development-and-production/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 10:14:49 +0000</pubDate>
		<dc:creator>Ian Serlin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[problem solution]]></category>
		<category><![CDATA[environments]]></category>
		<category><![CDATA[externalinterface]]></category>
		<category><![CDATA[production]]></category>

		<guid isPermaLink="false">http://ianserlin.com/?p=67</guid>
		<description><![CDATA[Very often there will be multiple environments that your application will be running under whether just for testing purposes or even multiple deployment domains. When running in a dev or test environment it can be useful or necessary to mock input/output or even just modify any urls your app is using if relative addresses aren&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Very often there will be multiple environments that your application will be running under whether just for testing purposes or even multiple deployment domains. When running in a dev or test environment it can be useful or necessary to mock input/output or even just modify any urls your app is using if relative addresses aren&#8217;t an option. If you&#8217;re creating an embeddable application it might be nice to know when your swf is loaded on your own domain versus a 3rd party&#8217;s.</p>
<p>In any case, you could write build scripts or you could manually change command-line compiler options or add them in Flex/Flash Builder or even just edit some xml config files before you deploy. For the most part, in most cases, that sucks. Repetitive non-thinking work sucks because you don&#8217;t like it and you&#8217;ll forget to do it and then all of a sudden shit will hit the fan in production because you forgot to update some random variable you&#8217;d rather forget about.
</p>
<h2>Problem</h2>
<p>You want your application to operate appropriately in whatever supported environment it&#8217;s run under.</p>
<h2>Solution</h2>
<p>If you&#8217;ve set up different domains to run your dev, test and production environments under (you should, just modify your hosts file) you can simply grab the url of the page your application was loaded in and switch your logic to use the correct server urls or whatever fork needs to happen based on environmental changes (good architecture should keep these forks to a minimum). The following function gets the base url for you:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> getWindowLocationBaseURL<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</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;">ExternalInterface</span>.<span style="color: #004993;">available</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">url</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #004993;">ExternalInterface</span>.<span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;function () { return window.location.protocol.toString().toLowerCase() + '//' + window.location.host.toString().toLowerCase(); }&quot;</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">url</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #990000;">&quot;&quot;</span>;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Then you can just do a:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> getWindowLocationBaseURL<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">indexOf</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;example.test&quot;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span> ... <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>to see what environment you&#8217;re running under.</p>
<h2>Gotchas</h2>
<p>The one nice thing about using build scripts or configs to solve this problem is that you can do conditional compilation which will reduce your final swf size. In my experience though the amount of additional space required to do the above is negligible, especially compared to satisfaction of not having to worry about it anymore.</p>
<p>How did you tackle the issue of multiple runtime environments? Let me know in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://ianserlin.com/index.php/2009/12/02/making-your-actionscript-3flex-project-work-correctly-in-both-development-and-production/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple JSON decoder for ActionScript 3/Flex</title>
		<link>http://ianserlin.com/index.php/2009/09/30/simple-json-decoder-for-actionscript-3flex/</link>
		<comments>http://ianserlin.com/index.php/2009/09/30/simple-json-decoder-for-actionscript-3flex/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 06:49:37 +0000</pubDate>
		<dc:creator>Ian Serlin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[problem solution]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://ianserlin.com/?p=97</guid>
		<description><![CDATA[In most of the use cases I come across JSON is my data format of choice for transmitting information between software systems. You might have seen the Adobe corelib JSON classes or even rolled your own, but there is a simpler way using native Javascript because, obviously, JSON is simply a Javascript representation of an [...]]]></description>
			<content:encoded><![CDATA[<p>In most of the use cases I come across JSON is my data format of choice for transmitting information between software systems. You might have seen the Adobe corelib JSON classes or even rolled your own, but there is a simpler way using native Javascript because, obviously, JSON is simply a Javascript representation of an native object. How you say? This way I say:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> decodeJSON<span style="color: #000000;">&#40;</span> <span style="color: #004993;">data</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> <span style="color: #000000;">&#123;</span>
     <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">ExternalInterface</span>.<span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;function(){return &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">data</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;}&quot;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>If you run into any problems using the above to decode JSON or you&#8217;ve written other cool JSON utilities let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://ianserlin.com/index.php/2009/09/30/simple-json-decoder-for-actionscript-3flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why IE doesn&#8217;t drop Flash NetConnections / NetStreams and how to fix it.</title>
		<link>http://ianserlin.com/index.php/2009/03/10/why-ie-doesnt-drop-flash-netconnections-netstreams-and-how-to-fix-it/</link>
		<comments>http://ianserlin.com/index.php/2009/03/10/why-ie-doesnt-drop-flash-netconnections-netstreams-and-how-to-fix-it/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 02:56:40 +0000</pubDate>
		<dc:creator>Ian Serlin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Wowza Media Server]]></category>
		<category><![CDATA[problem solution]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[netconnection]]></category>
		<category><![CDATA[netstream]]></category>

		<guid isPermaLink="false">http://ianserlin.com/?p=7</guid>
		<description><![CDATA[Problem
The Adobe Flash Player ActiveX control for Internet Explorer 7 (I don&#8217;t know about IE6) will not disconnect NetConnections if the connection was made by a swf instance loaded in a tab and only that tab was closed. If IE itself is closed though the NetConnection will be dropped. This could lead to hung &#8220;ghost&#8221; [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>The Adobe Flash Player ActiveX control for Internet Explorer 7 (I don&#8217;t know about IE6) will not disconnect NetConnections if the connection was made by a swf instance loaded in a tab and only that tab was closed. If IE itself is closed though the NetConnection will be dropped. This could lead to hung &#8220;ghost&#8221; connections where you won&#8217;t hear any audio, etc. but your <a title="Wowza Media Server Pro" href="http://wowzamedia.com">Wowza Media Server</a> (and maybe Flash Media Server, who knows?) will still think the client is connected.</p>
<h2>Explanation</h2>
<p>Laziness on the part of two large corporations.</p>
<h2>Solution</h2>
<p>Register a JS handler function for window.onbeforeunload that uses the Flash ExternalInterface to call a function in your swf that manually closes the NetConnection. The event &#8220;onbeforeunload&#8221; is recognized and executed by IE, Safari and Firefox before the onunload event is fired. It is apparently not handled by Opera AFAIK but that&#8217;s ok since IE is the only one that actually needs this fix.</p>
<p>In your ActionScript 3 code somewhere:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.external</span>.<span style="color: #004993;">ExternalInterface</span>;
&nbsp;
....
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> someFunction<span style="color: #000000;">&#40;</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>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">ExternalInterface</span>.<span style="color: #004993;">available</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
&nbsp;
<span style="color: #004993;">ExternalInterface</span>.<span style="color: #004993;">addCallback</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;disconnect&quot;</span>, disconnect<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> disconnect<span style="color: #000000;">&#40;</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>
&nbsp;
_my_net_connection1.<span style="color: #004993;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>In your Javascript code for the page that loads your swf:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
window.<span style="color: #660066;">onbeforeunload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// pure JS</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> swf <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mySwf'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
swf.<span style="color: #660066;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// jQuery 1.2.6 version</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mySwf&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The End</p>
]]></content:encoded>
			<wfw:commentRss>http://ianserlin.com/index.php/2009/03/10/why-ie-doesnt-drop-flash-netconnections-netstreams-and-how-to-fix-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

