Jump to content


Flash talking to MySql


  • You cannot reply to this topic
2 replies to this topic

#1 indosilver

    Young Padawan

  • Members
  • Pip
  • 5 posts
  • Interests:Wannabe Admin

Posted 11 October 2006 - 07:36 PM

Anyone have any clue where i would start on this?

i need to get flash to talk to MySql, it's for a website navigation, and i want it to be easy to change links for the user

any help would be appreciated =D

#2 PixelHiveDesign

    Young Padawan

  • Members
  • Pip
  • 83 posts
  • Gender:Male

Posted 11 October 2006 - 10:20 PM

Here are 2 methods.

1) Have PHP generate an XML formatted file with the navigation information whenever the client updates the database.
Then have Flash load and parse the XML file.

2) Use the loadVariables function in Flash to call a PHP page which will return the information formatted into a variable string like: nav0=home&nav1=services&nav2=portfolio etc.

It all depends on how flexible you need it to be and how much information you need to gather from mySQL. Method 1 will allow you to do almost anything, while method 2 is easier to setup... it is less flexible.

Anyway, hope it helps you start.

Max (PHD)

#3 Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 12 October 2006 - 12:47 AM

Well, the best way to do it is the first suggestion by PHD. You want to load the MySQL into a PHP file, output it as xml, and insert it into Flash. Something like this:
PHP:
$query = "SELECT * FROM links ORDER BY name DESC";
echo("<?xml version='1.0'?><links>");
while($row = mysql_fetch_array($query)) {
echo("<link name='".$row["name"]."' href='".$row["href"]."' />");
}
echo("</links");
FLASH:
var myXML:XML = new XML();
var totalLinks:Number;
myXML.ignoreWhite = true;
myXML.onLoad = function(success:Boolean) {
if(success) {
totalLinks = myXML.firstChild.childNodes.length;
for(var i = 0; i < totalLinks; i++) {
//trace(myXML.firstChild.childNodes[i].attributes["name"]);
}
}
}
myXML.load("phpfile.php");

Edited by d4rkst0n3, 12 October 2006 - 12:48 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users