Hy I finally got all the errors out of the world with a news script which reads data out of mySql and converts it into an xml-File and then loads it into Flash.
It's realy slow! it takes about 20 seconds when the cache is empty.
Here is what I found out till now. If I just put in the url to the the php file which creates the xml it's fast. Then if I copie that file and paste it into an xml file and then say load(xml) unstead of load(php) it's also fast. So I guess there is a Problem with Flash interpreting the php file that creates the xml. Like I said it does work, but just realy takes to long to load. Here ist the php I use:
Code:
<?php
$link = mysql_connect(".",".",".");
mysql_select_db(".");
$query = 'SELECT * FROM news ORDER BY id DESC';
$results = mysql_query($query);
$line = mysql_num_rows($results);
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
echo "<news>\n";
echo "<n>" . $line. "</n>\n";
while($line = mysql_fetch_assoc($results)) {
echo "<event>\n";
echo "<title>" . $line["titel"] . "</title>\n";
echo "<date>" . date("d.m.y", strtotime($line["datum"])) . "</date>\n";
echo "<text>" . $line["text"] . "</text>\n";
echo "<url>" . $line["link"] . "</url>\n";
echo "</event>\n";
}
echo "</news>\n";
mysql_close($link);
?>
And here the flash I use:
Code:
function loadXMLNews(loaded) {
if (loaded) {
// If XML file is loaded this will open Cover
_root.cover.gotoAndPlay(2);
// Geting information from XML object and puting it in text fields
_global.number = this.firstChild.firstChild.childNodes[0].nodeValue;
_root.news_title.text = this.firstChild.childNodes[_global.sel].childNodes[0].firstChild.nodeValue;
_root.news_date.text = this.firstChild.childNodes[_global.sel].childNodes[1].firstChild.nodeValue;
_root.news_text_field.text = this.firstChild.childNodes[_global.sel].childNodes[2].firstChild.nodeValue.split("\r\n").join("\n");
_root.news_num_display.text = _global.sel+"/"+_global.number;
_global.related_link = this.firstChild.childNodes[_global.sel].childNodes[3].firstChild.nodeValue;
if (_global.related_link=="leer") {_root.linkbutton._visible=false;} else {_root.linkbutton._visible=true;}
// last line hides Link button if there is no link related to entry
if (_global.number=="1") {_root.linkweiter._visible=false;} else {_root.linkweiter._visible=true;}
// last line hides Link button if there is no link related to entry
} else {
trace("file dog.xml not loaded!");
// shown in output pane if dog.xml from some reason is not readible
}
}
function LoadNews() {
xmlNews = new XML();
// instancing new XML object
xmlNews.ignoreWhite = true;
// ignore white spaces in XML file
xmlNews.onLoad = loadXMLNews;
// trigger loadXMLNews function when loading is finished.
xmlNews.load("test.xml");
// specify which file to open
}
_global.sel = 1;
// sets defauls entry number, the first one.
LoadNews();
Does anyone know how to solve this problem? I would realy aprechiate any sugestions. Thank you all! Rilana