Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Having trouble downloading MySQL to Flash

Posted on 2011-02-26
3
Medium Priority
?
299 Views
Last Modified: 2013-11-11
I need the experts on this one...

I have some code but need some help making it work...

I am trying to display data from a mySQL database to a datagrid or listbox...

The php code is working as it was tested in the browser but the actionscript is playing difficult...

Here is my code in Flash:

var theXML:XML = new XML();
theXML.ignoreWhite = true;

theXML.onLoad = function(){
	var nodes = this.firstChild.childNodes;
	var i:Number;
	for(i=0;i<nodes.length;i++){
		testList.addItem(nodes[i].firstChild.nodeValue);
	}
	
	
}
theXML.load("http://mysite/myfile.php");

Open in new window

The main problem is that AS3 is not recognizing the load request and onLoad handler...

I just need to be pointed in the right direction on this one...How can the above code be written in AS3?
0
Comment
Question by:eager_to_learn
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
CyanBlue earned 2000 total points
ID: 34990359
That's AS2 code...  ;)

Check out this tutorial on how to do that with AS3...
   http://www.republicofcode.com/tutorials/flash/as3xml/

CyanBlue
0
 

Author Comment

by:eager_to_learn
ID: 34991673

Thanks CyanBlue for responding...

After a few hours of playing around with the code I came up with this working model:
var file:String = "/scripts/Product.php";
var xmlData:XML= new XML()

var theURL_ur:URLRequest = new URLRequest(file);
var loader_ul:URLLoader = new URLLoader(theURL_ur);
loader_ul.addEventListener(Event.COMPLETE, fileLoaded);

function fileLoaded(e:Event):void
{
xmlData = XML(loader_ul.data);

var array = xmlData.children();
var howMany = xmlData.children().length();

	for(var i = 0; i < howMany; i++) {
		TestGrid.addItem({UPC:array[i]});
	}
}

Open in new window

Thanks.
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 34991731
Glad to hear that you've got it working...  Please close the topic...  ;)

CyanBlue
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While Plesk offers many potential benefits to website administrators, including compatibility with Windows Server and other leading technologies, the company has also been working to differentiate it from other control panels for content management…
Eseutil Hard Recovery is part of exchange tool and ensures Exchange mailbox data recovery when mailbox gets corrupt due to some problem on Exchange server.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question