?
Solved

PHP, MySQL,and Flash

Posted on 2010-03-23
10
Medium Priority
?
280 Views
Last Modified: 2012-05-09
I did that this guy did

http://library.creativecow.net/articles/brimelow_lee/php_mysql/video-tutorial.php

And it's not working i am using flash cs4.  

php code works great it displays the data just find.


<?

mysql_connect("localhost", "name", "password") or die(mysql_error());
mysql_select_db("Flash") or die(mysql_error());
$query="SELECT * FROM products";
$result=mysql_query($query);

echo "<?xml version=\"1.0\"?>\n";
echo "<products>\n";

while($line = mysql_fetch_assoc($result)) {
	echo "<item>" . $line["product"] . "</item>\n";

}

echo "</products>\n";


mysql_close();



?>




The flash code is 

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

theXML.onLoad = function() {
	var nodes = this.firstChild.childNodes;
	for(i=0;i<nodes.lenght;i++) {
		theList.addItem(nodes[i].firstChild.nodeValue,i);
	}
}

theXML.load("http://www.mysite.com/flash.php");

When i try to view the flash file is goes in some crazy blinking.

Open in new window

flash-php-mysql-integration-Scen.swf
0
Comment
Question by:ccaseyhns
  • 5
  • 5
10 Comments
 
LVL 37

Expert Comment

by:CyanBlue
ID: 28371079
I don't know what you meant by the 'crazy blinking', but it sounds like you might have some error happening with your ActionScript...  Do you get any error message when you create the SWF file???

CyanBlue
0
 

Author Comment

by:ccaseyhns
ID: 28371699
line 6 1120: Access of undefined property i.

line 7 1137: Incorrect number of arguments.  Expected no more than 1.

line 4 Warning: 1090: Migration issue: The onLoad event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0.  You must first register this handler for the event using addEventListener ( 'load', callback_handler).

line 11 Warning: 3594: load is not a recognized method of the dynamic class XML.
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 28372459
It sounds like the tutorial is done in AS2 and you are trying to compile it in AS3...  Try using AS2 and see if that works for you...

CyanBlue
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 

Author Comment

by:ccaseyhns
ID: 28372996
yep tried that and it doesn't display the xml just a blank list box.

but if i run the php code it displays the database info.
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 28373231
Are you testing it inside the Flash IDE???

Try changing the theXML.onLoad handler to this and see if you get anything in the Output panel...

CyanBlue
theXML.onLoad = function() {
	var nodes = this.firstChild.childNodes;
	for(var i:Number = 0 ; i < nodes.lenght ; i++) {
		trace("nodeValue " + i + " = " + nodes[i].firstChild.nodeValue);
		theList.addItem(nodes[i].firstChild.nodeValue, i);
	}
}

Open in new window

0
 

Author Comment

by:ccaseyhns
ID: 28373908
yes i and doing a test movie in flash

try the new code and tested on web server still no output
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 28374813
No, I was asking that because I wanted you test inside the Flash IDE to see if the trace line that I added works or not...

CyanBlue
0
 

Author Comment

by:ccaseyhns
ID: 28375703
well i tried just a xml file and still no output
<?xml version="1.0"?>
<products>
<item>Why do people die</item>
<item>Why do you like pie</item>
</products>


and this as the flash code 

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

theXML.onLoad = function() {
        var nodes = this.firstChild.childNodes;
        for(var i:Number = 0 ; i < nodes.lenght ; i++) {
                trace("nodeValue " + i + " = " + nodes[i].firstChild.nodeValue);
                theList.addItem(nodes[i].firstChild.nodeValue, i);
        }
}

theXML.load("display.xml");

Open in new window

0
 
LVL 37

Accepted Solution

by:
CyanBlue earned 2000 total points
ID: 28376804
Aha...  There is a typo in 'lenght' which should be 'length'...
   for (var i:Number = 0; i < nodes.length; i++)

CyanBlue
0
 

Author Closing Comment

by:ccaseyhns
ID: 31706211
God Damn i hate typo

Thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

601 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