Solved

Having trouble downloading MySQL to Flash

Posted on 2011-02-26
3
293 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 500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using in clause in query with many values 7 45
MySQL: Updating SubQuery Match Faster 9 46
MySQL - Restore Database SQL File 5 41
Amazon Redshift 2 26
In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Viewers will learn how to use the Hootsuite Dashboard.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now