<?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>Turtlebite&#039;s Blog &#187; server</title>
	<atom:link href="http://blog.turtlebite.com/tag/server/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.turtlebite.com</link>
	<description>Flash CMS Framework, Fleb Framework, Global Navigation and other ActionScript Stuff</description>
	<lastBuildDate>Thu, 17 Nov 2011 06:01:29 +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>Send and load variables with AS3 and PHP</title>
		<link>http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/</link>
		<comments>http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/#comments</comments>
		<pubDate>Sat, 21 Feb 2009 18:05:45 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[Utilities & Tips]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash php]]></category>
		<category><![CDATA[send load variables]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://www.flashcmsframework.ch/?p=49</guid>
		<description><![CDATA[Because I use this all the time I decided to put the handling of loading variables with AS3 and PHP in a handy little class. The usage is really simple: new VarLoader(&#34;yourscript.php&#34;,{var1:value1, var2:value2}) But before explaining everything in detail, lets look at this example: 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_varloader_1604636609"
			class="flashmovie"
			width="595"
			height="480">
	<param name="movie" value="/wp-content/data/varloader/varloader.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/data/varloader/varloader.swf"
			name="fm_varloader_1604636609"
			width="595"
			height="480">
	<!--<![endif]-->
		 
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object> The complete AS3 code [...]]]></description>
			<content:encoded><![CDATA[<p>Because I use this all the time I decided to put the handling of loading variables with AS3 and PHP in a handy little class. The usage is really simple:<span id="more-49"></span></p>
<p><code>
<pre class="brush: php;">new VarLoader(&quot;yourscript.php&quot;,{var1:value1, var2:value2})</pre>
<p></code></p>
<p>But before explaining everything in detail, lets look at this example:<strong><br />
</strong></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_varloader_174463756"
			class="flashmovie"
			width="595"
			height="480">
	<param name="movie" value="/wp-content/data/varloader/varloader.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/data/varloader/varloader.swf"
			name="fm_varloader_174463756"
			width="595"
			height="480">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img class="alignnone size-full wp-image-731" title="flash-as3-php-send-load-variables" src="http://blog.flashcmsframework.com/wp-content/uploads/2009/02/flash-as3-php-send-load-variables.jpg" alt="flash-as3-php-send-load-variables" width="190" height="140" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The complete AS3 code in varloader.swf:</p>
<pre class="brush: php;">
import net.kaegi.loaders.VarLoader;
var vl:VarLoader;
//
sendBtn.addEventListener(MouseEvent.CLICK,sendBtnHandler);
function sendBtnHandler(e:MouseEvent) {
// Variables sent by POST-Method:
var varObj:Object = {};
varObj.textinput0 = escape(textinput0.text);
varObj.textinput1 = escape(textinput1.text);
// additionally another variable is sent by the GET method:
vl = new VarLoader(&quot;http://www.flashcmsframework.ch/wp-content/data/varloader/varloader.php?var_get=I was sent by GET!&quot;, varObj);
vl.addEventListener(Event.COMPLETE, onVarsLoaded);
vl.addEventListener(Event.CANCEL, onVarsCancel);
}
function onVarsLoaded(e:Event) {
var msg:String = &quot;Communication with the server was successful.\n\n&quot;;
msg += &quot;bulla -&gt; &quot;+e.target.vars.bulla+&quot;\n&quot;;
msg += &quot;gogull -&gt; &quot;+unescape(e.target.vars.gogull)+&quot;\n&quot;;
msg += &quot;var33 -&gt; &quot;+unescape(e.target.vars.var33)+&quot;\n&quot;;
msg += &quot;var_get -&gt; &quot;+unescape(e.target.vars.var_get)+&quot;\n&quot;;
msg += &quot;textinput0 -&gt; &quot;+unescape(e.target.vars.textinput0)+&quot;\n&quot;;
msg += &quot;textinput1 -&gt; &quot;+unescape(e.target.vars.textinput1)+&quot;\n&quot;;
tf_servermsg.textColor = 0x009900;
tf_servermsg.text = msg;
}
function onVarsCancel(e:Event) {
tf_servermsg.textColor = 0x990000;
tf_servermsg.text = e.target.errormsg;
}
</pre>
<p>&#8230;and the code in varloader.php:</p>
<pre class="brush: php;">

// coming from flash (GET)
$var_get = $_GET[&quot;var_get&quot;];

// coming from flash (POST)
$textinput0 = $_POST[&quot;textinput0&quot;];
$textinput1 = $_POST[&quot;textinput1&quot;];

// internal
$bulla = &quot;Blabla. I am just some lonely text.....&quot;;
$gogull = &quot;WOW! I was fetched from the server as well! Cool!&quot;;
$var33 = &quot;Hey, my name is 'var33'! What's yours?&quot;;

// result:
$result = &quot;foo=bar&quot;;     // In AS3 the first variable MUST NOT have an '&amp;', otherwise you will get an error message! So just use some dummy vars to make flash happy.
$result .= &quot;&amp;bulla=&quot;.rawurlencode($bulla);
$result .= &quot;&amp;gogull=&quot;.rawurlencode($gogull);
$result .= &quot;&amp;var33=&quot;.rawurlencode($var33);
$result .= &quot;&amp;var_get=&quot;.rawurlencode($var_get);
$result .= &quot;&amp;textinput0=&quot;.rawurlencode($textinput0);
$result .= &quot;&amp;textinput1=&quot;.rawurlencode($textinput1);

echo $result;

?&gt;;
</pre>
<p><a href="http://blog.turtlebite.com/wp-content/data/varloader/varloader.zip">Download source code and example file</a></p>
<p>I hope someone can use this!</p>
<p><strong>Update 12/28/2009: Some useful links regarding url encoding:</strong><br />
<a href="http://help.adobe.com/en_US/AIR/1.1/jslr/package.html#escape()">escape()</a><br />
<a href="http://help.adobe.com/en_US/AIR/1.1/jslr/package.html#unescape()">unescape()</a><br />
<a href="http://help.adobe.com/en_US/AIR/1.1/jslr/package.html#encodeURI()">encodeURI()</a><br />
<a href="http://help.adobe.com/en_US/AIR/1.1/jslr/package.html#encodeURIComponent()">encodeURIComponent()</a><br />
<a href="http://help.adobe.com/en_US/AIR/1.1/jslr/package.html#decodeURI()">decodeURI()</a><br />
<a href="http://help.adobe.com/en_US/AIR/1.1/jslr/package.html#decodeURIComponent()">decodeURIComponent()</a></p>
<p>Cheers,<br />
Christian</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/&amp;title=Send+and+load+variables+with+AS3+and+PHP" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/&amp;title=Send+and+load+variables+with+AS3+and+PHP" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/&amp;title=Send+and+load+variables+with+AS3+and+PHP&amp;desc=Because%20I%20use%20this%20all%20the%20time%20I%20decided%20to%20put%20the%20handling%20of%20loading%20variables%20with%20AS3%20and%20PHP%20in%20a%20handy%20little%20class.%20The%C2%A0usage%20is%20really%20simple%3A%0D%0A%0D%0A%5Bcode%20lang%3D%22php%22%5Dnew%20VarLoader%28%26quot%3Byourscript.php%26quot%3B%2C%7Bvar1%3Avalue1%2C%20var2%3Avalue2%7D%29%5B%2Fcode%5D%0D%0A%0D%0A%0D%0A%0D%0ABut%20before%20explaining%20everything%20in%20detail%2C" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/&amp;bm_description=Send+and+load+variables+with+AS3+and+PHP&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/&amp;title=Send+and+load+variables+with+AS3+and+PHP" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/&amp;title=Send+and+load+variables+with+AS3+and+PHP" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/&amp;title=Send+and+load+variables+with+AS3+and+PHP" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Send+and+load+variables+with+AS3+and+PHP+-+http://b2l.me/afqp84&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.turtlebite.com/send-and-load-variables-with-as3-and-php/feed/</wfw:commentRss>
		<slash:comments>53</slash:comments>
		</item>
	</channel>
</rss>

