<?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>theDeSilva.com&#187; parameters</title>
	<atom:link href="http://www.thedesilva.com/tag/parameters/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thedesilva.com</link>
	<description>Andrew de Silva</description>
	<lastBuildDate>Wed, 04 Aug 2010 19:27:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Retrieve Flash Variables in Actionscript 3</title>
		<link>http://www.thedesilva.com/2008/06/retrieve-flash-variables-in-actionscript-3/</link>
		<comments>http://www.thedesilva.com/2008/06/retrieve-flash-variables-in-actionscript-3/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 19:17:56 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[flash variables]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[query string]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=35</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//flash_small.png" width="32" height="32" alt="" title="Flash" /><br/>Previously, in ActionScript 2.0, you could pass variables along the query string or using FlashVars and the variables would be available in _level0, in ActionScript 3.0, it is a bit different . In Actionscript 3 variables that are passed in through query string have been moved to the parameters property of LoaderInfo instance. Here&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//flash_small.png" width="32" height="32" alt="" title="Flash" /><br/><p>Previously, in ActionScript 2.0, you could pass variables along the query string or using FlashVars and the variables would be available in _level0, in ActionScript 3.0, it is a bit different . In Actionscript 3 variables that are passed in through query string have been moved to the parameters property of LoaderInfo instance. Here&#8217;s a real simple way to retrieve flash variable in Actionscript 3</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;object classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot; width=&quot;550&quot; height=&quot;400&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot;&gt;
     &lt;param name=&quot;src&quot; value=&quot;somefilename.swf?fileName=info&quot; /&gt;
     &lt;embed type=&quot;application/x-shockwave-flash&quot; width=&quot;550&quot; height=&quot;400&quot; src=&quot;somefilename.swf?fileName=info&quot;&gt;&lt;/embed&gt;
&lt;/object&gt;</pre></td></tr></table></div>

<p>To access the query string fileName in Actionscript 3 , all you have to do in your actionscript 3 source code is</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> fileName:<span style="color: #0066CC;">String</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
fileName = root.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>.<span style="color: #006600;">fileName</span></pre></td></tr></table></div>

<p>Here&#8217;s another way to loop through your flash variables</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
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> tf:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
tf.<span style="color: #0066CC;">autoSize</span> = TextFieldAutoSize.<span style="color: #0066CC;">LEFT</span>;
tf.<span style="color: #0066CC;">border</span> = <span style="color: #000000; font-weight: bold;">true</span>;
addChild<span style="color: #66cc66;">&#40;</span>tf<span style="color: #66cc66;">&#41;</span>;
&nbsp;
tf.<span style="color: #006600;">appendText</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;params:&quot;</span> + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> keyStr:<span style="color: #0066CC;">String</span>;
    <span style="color: #000000; font-weight: bold;">var</span> valueStr:<span style="color: #0066CC;">String</span>;
    <span style="color: #000000; font-weight: bold;">var</span> paramObj:<span style="color: #0066CC;">Object</span> = LoaderInfo<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #006600;">root</span>.<span style="color: #006600;">loaderInfo</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parameters</span>;
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>keyStr <span style="color: #b1b100;">in</span> paramObj<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        valueStr = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>paramObj<span style="color: #66cc66;">&#91;</span>keyStr<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
        tf.<span style="color: #006600;">appendText</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> + keyStr + <span style="color: #ff0000;">&quot;:<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> + valueStr + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</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><span style="color: #0066CC;">error</span>:<span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    tf.<span style="color: #006600;">appendText</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2008/06/retrieve-flash-variables-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
