Pulling data from mysql db in AS3

How do you pull data from a mysql database in AS3?

I’d suggest using an xml file made by php. are you okay with php ?

You would use something like this to reference a php file;

package {
	import flash.display.*;
	import flash.net.URLVariables;
	import flash.net.URLLoader;
	import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequest;
	import flash.net.URLRequestMethod;
	import flash.net.URLRequest;
	import flash.events.*;

	public class QueryDataBase extends Sprite {
		
		public static  const DATA_ACCESSED:String = "dataaccesed";

		public function QueryDataBase() {

			var myData:URLRequest = new URLRequest("get.php");
			myData.method = URLRequestMethod.GET;
			var variables:URLVariables = new URLVariables();
			myData.data = variables;
			var loader:URLLoader = new URLLoader();
			loader.dataFormat = URLLoaderDataFormat.VARIABLES;
			loader.addEventListener(Event.COMPLETE, dataOnLoad);
			loader.load(myData);
		}
		private function dataOnLoad(event:Event):void {
			trace(event.target.data)
                        dispatchEvent(new Event(QueryDataBase.DATA_ACCESSED, true));
		}
	}
}

Then, of course you need a php file, that will parse your database, and return something. Depending on your needs, you could just use a string, or get PHP to return an XML doc. You can probably change the class to extend something other than sprite. That was a snippet of some other larger, class.

Thank you Dail. I’ll give this a try. I’m fairly new to php but I love learning it and was wondering how to pull data from mysql. AS3 has change dramatically the last time I dove into it. Now I can try to bridge the 2. I was trying to pass the info via JS.

So ideally I should be processing a xml file. would this method work if I wanted to process a xml file?

http://www.google.ru/search?q=AS3+MySQL