<?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>FlashBannerOnline &#187; FLEX</title>
	<atom:link href="http://blog.flashbanneronline.com/category/tutorials/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flashbanneronline.com</link>
	<description>Online Flash Banner Generator blog!</description>
	<lastBuildDate>Sun, 26 Jun 2011 11:38:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using URLLoader to send and load Data to Server Used FLEX</title>
		<link>http://blog.flashbanneronline.com/2010/02/using-urlloader-to-send-and-load-data-to-server-used-flex/</link>
		<comments>http://blog.flashbanneronline.com/2010/02/using-urlloader-to-send-and-load-data-to-server-used-flex/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 22:55:56 +0000</pubDate>
		<dc:creator>Behrouz Pooladrag</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA["urlloader.php?url="]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[actionscript 3 sendandload php]]></category>
		<category><![CDATA[adobe flex urlloader]]></category>
		<category><![CDATA[as2 url load]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[as3 "adobe air" "login" php]]></category>
		<category><![CDATA[as3 flash.net]]></category>
		<category><![CDATA[as3 loadandsend php]]></category>
		<category><![CDATA[as3 mysql data]]></category>
		<category><![CDATA[as3 nysql banner and text]]></category>
		<category><![CDATA[as3 reload url]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[flash as2 login php mysql]]></category>
		<category><![CDATA[flash as2 php database sample]]></category>
		<category><![CDATA[flash as3 urlrequest variable]]></category>
		<category><![CDATA[flash cs4 mysql php]]></category>
		<category><![CDATA[flash load and send]]></category>
		<category><![CDATA[flash load url]]></category>
		<category><![CDATA[flash loader using coding]]></category>
		<category><![CDATA[flash php mysql as3 login]]></category>
		<category><![CDATA[flash send and load data]]></category>
		<category><![CDATA[flash servlet xml example]]></category>
		<category><![CDATA[flash to php data using urlloader]]></category>
		<category><![CDATA[flash urlrequest login sample]]></category>
		<category><![CDATA[flash.net.URLLoader]]></category>
		<category><![CDATA[flex 3 urlloader reload]]></category>
		<category><![CDATA[flex and php communication through xml]]></category>
		<category><![CDATA[flex con servlet]]></category>
		<category><![CDATA[flex php urlloader]]></category>
		<category><![CDATA[flex record and send to server]]></category>
		<category><![CDATA[flex retreive string from servlet senddata]]></category>
		<category><![CDATA[flex return mysql data]]></category>
		<category><![CDATA[flex servlet url swf/dynamic/3]]></category>
		<category><![CDATA[flex url loader servlet]]></category>
		<category><![CDATA[flex urlloader]]></category>
		<category><![CDATA[flex urlloader variables]]></category>
		<category><![CDATA[flex urlrequest string variable]]></category>
		<category><![CDATA[flex urlrequestmethod.post urlloader]]></category>
		<category><![CDATA[flex urlvariables php]]></category>
		<category><![CDATA[flex with mysql using as3]]></category>
		<category><![CDATA[how to send data throught urlrequest in flex]]></category>
		<category><![CDATA[how to send data to server in flash as3]]></category>
		<category><![CDATA[input data flash mysql]]></category>
		<category><![CDATA[ip:207.182.137.187 id]]></category>
		<category><![CDATA[load a flash object file from mysql]]></category>
		<category><![CDATA[load data from post urlloader]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[on release flash.net.urlloader]]></category>
		<category><![CDATA[passing data mysql flash]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php flash servlet]]></category>
		<category><![CDATA[php load url]]></category>
		<category><![CDATA[reload data from mysql in flash cs4]]></category>
		<category><![CDATA[sample flash as3 classes]]></category>
		<category><![CDATA[send and load as3]]></category>
		<category><![CDATA[send and load flash as3 php mysql]]></category>
		<category><![CDATA[send data urlrequest]]></category>
		<category><![CDATA[send load php as3]]></category>
		<category><![CDATA[send param with url loader flex]]></category>
		<category><![CDATA[send variables to flex from php]]></category>
		<category><![CDATA[SendAndLoad]]></category>
		<category><![CDATA[sendandload as2 error loading url]]></category>
		<category><![CDATA[sendandload con actionscript 3.0 y mysql]]></category>
		<category><![CDATA[sendandload in as3 with php]]></category>
		<category><![CDATA[sending data from flex to servlet]]></category>
		<category><![CDATA[sending data to server as3]]></category>
		<category><![CDATA[sending request from flex to servlet]]></category>
		<category><![CDATA[servlet load data mysql]]></category>
		<category><![CDATA[to pass data from flash to mysql database using as3]]></category>
		<category><![CDATA[trace("par: " loader.data.par);]]></category>
		<category><![CDATA[url loader flex]]></category>
		<category><![CDATA[url loader send as3]]></category>
		<category><![CDATA[URLLoader]]></category>
		<category><![CDATA[urlloader as2]]></category>
		<category><![CDATA[urlloader class php]]></category>
		<category><![CDATA[urlloader com php my sql]]></category>
		<category><![CDATA[urlloader data]]></category>
		<category><![CDATA[urlloader flex]]></category>
		<category><![CDATA[urlloader flex php lightspeed problem]]></category>
		<category><![CDATA[urlloader par]]></category>
		<category><![CDATA[urlloader responce]]></category>
		<category><![CDATA[urlloader to pass data]]></category>
		<category><![CDATA[urlloader urlvariables]]></category>
		<category><![CDATA[urlloader.sendandload()]]></category>
		<category><![CDATA[URLLoaderDataFormat]]></category>
		<category><![CDATA[URLRequest]]></category>
		<category><![CDATA[urlrequest method post flex]]></category>
		<category><![CDATA[URLRequestMethod]]></category>
		<category><![CDATA[URLVariables]]></category>
		<category><![CDATA[urlvariables custom flex]]></category>
		<category><![CDATA[write text file using urlloader actionscript 3]]></category>
		<category><![CDATA[xmlloader:flash.net.urlloader]]></category>

		<guid isPermaLink="false">http://blog.flashbanneronline.com/?p=328</guid>
		<description><![CDATA[Here is a very simple example of two way communication with database using Flex and PHP. In this example, we are sending username and password to the PHP file from Flex. PHP file then validates the input and returns the appropriate response. This example also demonstrates the simple PHP script to establish a database (MySQL) [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a very simple example of two way communication with database using Flex and PHP. In this example, we are sending username and password to the PHP file from Flex. PHP file then validates the input and returns the appropriate response.</p>
<p>This example also demonstrates the simple PHP script to establish a database (MySQL) connection and validate username and password against the table in database.</p>
<p>In AS3, we can use flash.net.URLLoader, URLRequest and URLVariables class to send and load data. First create a class named SendAndLoadExample.</p>
<p>Class SendAndLoadExample:</p>
<pre class="brush: as3; title: ; notranslate">
package {

import flash.events.*
import flash.net.*;

public class SendAndLoadExample {

public function SendAndLoadExample() {}
public function sendData(url:String, _vars:URLVariables):void {
var request:URLRequest = new URLRequest(url);
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request.data = _vars;
request.method = URLRequestMethod.POST;
loader.addEventListener(Event.COMPLETE, handleComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.load(request);
}
private function handleComplete(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace(&quot;Par: &quot; + loader.data.par);
trace(&quot;Message: &quot; + loader.data.msg);
}
private function onIOError(event:IOErrorEvent):void {
trace(&quot;Error loading URL.&quot;);
}
}
}
</pre>
<p>Now, create an object of SendAndLoadExample class in Flex.</p>
<p>SendAndLoadExample.mxml</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
		layout=&quot;vertical&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
import flash.net.URLVariables;
private var mySendAndLoadExample:SendAndLoadExample;
mySendAndLoadExample = new SendAndLoadExample();
private function sendAndLoad():void {
var url:String = &quot;http://[your server]/login.php&quot;;
var variables:URLVariables = new URLVariables();
variables.UserName = &quot;tushar&quot;;
variables.Password = &quot;my_password&quot;;
mySendAndLoadExample.sendData(url, variables);
}
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:Button label=&quot;Fetch data&quot; click=&quot;sendAndLoad()&quot;/&gt;
&lt;/mx:Application&gt;
</pre>
<p>PHP file for login check: login.php</p>
<pre class="brush: php; title: ; notranslate">

&lt;?
$clientUserName=$_POST['UserName'];
$clientPassword=$_POST['Password'];
//////////////////////////////////////
// Host name
$host=&quot;[your server]&quot;;
// Mysql username
$username=&quot;[MySql database username]&quot;;
// Mysql password
$password=&quot;[MySql database password]&quot;;
// Database name
$db_name=&quot;[MySql database name]&quot;;
// Table name
$tbl_name=&quot;[MySql table name having usernames and passwords]&quot;;
function makeConnection() {
// Connect to server and select databse.
mysql_connect(&quot;$GLOBALS[host]&quot;, &quot;$GLOBALS[username]&quot;,
		&quot;$GLOBALS[password]&quot;)or die(&quot;cannot connect&quot;);
mysql_select_db(&quot;$GLOBALS[db_name]&quot;)or die(&quot;cannot select DB&quot;);
}
function fireQuery($query) {
$result=mysql_query($query);
return $result;
}
function printOutput($code, $msg){
print &quot;par=$code&amp;msg=$msg&quot;;
}
//////////////////////////////////////
function checkUserID($id, $password) {
$sql=&quot;SELECT * FROM $GLOBALS[tbl_name] WHERE
		userName='$id' and password='$password'&quot;;
$result=fireQuery($sql);
$count=mysql_num_rows($result);
if($count==1){
return true;
}
return false;
}
function init(){
if(isSet($GLOBALS[&quot;clientUserName&quot;])
	&amp;&amp; isSet($GLOBALS[&quot;clientPassword&quot;])){
makeConnection();
if(checkUserID($GLOBALS[&quot;clientUserName&quot;]
	, $GLOBALS[&quot;clientPassword&quot;])){
printOutput(&quot;1&quot;, &quot;Login successful.&quot;);
} else {
printOutput(&quot;0&quot;, &quot;Failed to login $GLOBALS[clientUserName].&quot;);
}
} else {
printOutput(&quot;0&quot;, &quot;Required parameters missing.&quot;);
}
}
init();
?&gt;
</pre>
<p>fin.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flashbanneronline.com/2010/02/using-urlloader-to-send-and-load-data-to-server-used-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced
Database Caching 6/30 queries in 0.091 seconds using disk: basic
Object Caching 916/1075 objects using disk: basic

Served from: blog.flashbanneronline.com @ 2012-02-11 13:11:41 -->
