1
votes

I am trying to retrieve mysql data using php(products.php) and return the data in xml format to ADobe flash as3; but i am getting following error.

Error opening URL 'http://localhost/Flash/player/products.php'

Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: http://localhost/Flash/player/products.php at php_mysql3_as3_fla::MainTimeline/frame1()

Please any suggestion or help why flash is not identifying the http://localhost/Flash/player/products.php addres. i have WAMP installed; which works fine as i have many other php projects working here.

Thanks in advance for help and suggestion.

THe following is my php code

<?php
    $link = mysql_connect("localhost","root","");

mysql_select_db("test");

$query = "select * from products";
$results = mysql_query($query);


echo '<?xml version="1.0" encoding="utf-8" ?>'." \n";
echo"<GALLERY>\n";
$cnt=0;
while($line=mysql_fetch_assoc($results))
{
    echo '<IMAGE TITLE="'.$cnt.'">'.$line['product'].'</IMAGE>'." \n";
    $cnt++;
}

echo "</GALLERY>\n";

mysql_close($link);

?>

the php file is located at c:\wamp\www\Flash\player\products.php


below is my AS3 flash code

var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

//myLoader.load(new URLRequest("c:\\wamp\\www\\Flash\\player\\products2.xml"));
myLoader.load(new URLRequest("http://localhost/Flash/player/products.php"));
myLoader.addEventListener(Event.COMPLETE, processXML);


function processXML(evt:Event):void {

myXML = new XML(evt.target.data);
for (var i:int = 0; i<myXML.*.length(); i++){
trace("My image number is " + (i+1) + ", it's title is " + myXML.IMAGE[i].@TITLE + " and it's URL is " + myXML.IMAGE[i]);
};
//trace("data: " + myLoader.data);;
}
2
Does the same URL work if you use it in your browser? Remember that Apache is case sensitive.shanethehat

2 Answers

3
votes

In chat it turned out the problem was a firewall.

Here is another related question:

Testing movie with Flash IDE fails to load file from localhost

0
votes

This might be possible:

  1. Your movie runs in the local realm, and you are trying to load a network resource (i guess this will be the case). In that case you need to add the compile flag: -use-network=true

  2. The php file does not exist.

You always need to catch the URLLoader events:

dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

to see what happened!

See these event handlers in action: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html#includeExamplesSummary