Solved

Having trouble downloading MySQL to Flash

Posted on 2011-02-26
3
290 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
Comment Utility
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
Comment Utility

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
Comment Utility
Glad to hear that you've got it working...  Please close the topic...  ;)

CyanBlue
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

772 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

11 Experts available now in Live!

Get 1:1 Help Now