Solved

Having trouble downloading MySQL to Flash

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
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…
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.
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.

820 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