Ultrashock Forums > Flash > Data Communication
how do I speed up load(php) ?

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
how do I speed up load(php) ?
Old 2008-11-20

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
postbit arrow 2 comments | 857 views postbit arrow Reply: with Quote   
Registered User
rilana is offline
seperator
Posts: 6
2008-08-23
seperator

Ultrashock Member Comments:
Laveklint's Avatar Laveklint Laveklint is offline Laveklint lives in Sweden 4 Creative Assets 2008-11-20 #2 Old  
sounds a bit strange... might wanna look into using AMFPHP, its really great.. however not sure that would solve your problem...
Reply With Quote  
rilana rilana is offline 2008-11-20 #3 Old  
thanks for you replay, I found out what the problem was, I used the embed font button some time on my way because I thaught it would help getting rid of my problem with δόφ and I totaly forgot about it, wo what it did is make everything realy slow... but I actualy still dont get why loading php would be different in speed then loading xml, it actually had nothing to do with it I guess... Thanks for the tip! I tryed installing AMFPHP once, but I had difficulties getting it to run on my server.... thank you and take care, Rilana
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: