使用PHP和XML有关Flash CS5加载图像从MySQL一个TileList [英] Load images to a TileList from Mysql using PHP and XML on Flash CS5

查看:129
本文介绍了使用PHP和XML有关Flash CS5加载图像从MySQL一个TileList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含PATH的将图像表的mysql数据库。

I have a mysql database with a table containing PATH's to images.

我要加载阿尔图像一个TileList。现在我有这个在PHP:

I want to load al the images to a TileList. Now i have this in PHP:

<?PHP

mysql_connect("localhost", "root", "root");
mysql_select_db("prototipo");

$result = mysql_query("select entretenimiento_id, e_nombre, e_imagen from          entretenimiento");

echo "<?xml version=\"1.0\" ?><entretenimiento>";

while($row = mysql_fetch_assoc($result))
{
    echo "<e_nombre>" . $row["e_nombre"] . "</e_nombre>";
    echo "<e_imagen>" . $row["e_imagen"] . "</e_imagen>";   
}

echo "</entretenimiento>";

?>

这应该是我拿的图像的路径,如此这般,显示图像平铺的标签上,名字带给我也ID,这样我就可以启动另一个查询时,该图像被点击。

This is supposed to fetch me the PATH of the image, the name so it goes on the label of the tile that displays the image, and brings me also the id so i can launch another query when that image is clicked on.

这一切都被设置成动态创建的XML。

All this is set into a dynamically created XML.

现在我的问题....我怎么加载此???怎么办ØAS3?我已经有AS3的TileList中,我只需要从PHP这种动态创建XML加载它。

Now my question.... How do i load this??? What to do o AS3?? I already have the AS3 for the tilelist, i only need to load this dynamically created XML from PHP to it.

在此先感谢。和遗憾,如果我搞砸了英语,它不是我的主要语言。林南美洲。

Thanks in advance. And sorry if i messed up on english, its not my main language. Im South American.

我有一个部分答案:

var path:String = "http://localhost/entretenimiento.php";
xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, onLoadComplete);
xmlLoader.load(new URLRequest(path));       

function onLoadComplete(e:Event):void {
    var xmlData:XML = new XML(e.target.data);
    //trace(xmlData);

    for (var i:int=0; i<xmlData.*.length(); i++)
    {
        myTileList.addItem({label:xmlData.e_nombre[i], source:xmlData.e_imagen[i]});
        //trace(xmlData.e_nombre[i]);
    }

}

Althought这显示我的图像和在地砖上的标题,我也得到两个更多个区块是空的,并且在跟踪它们被示出为未定义。任何想法这是为什么?

Althought this shows me the images and the titles on the tiles, i also get two more tiles that are empty, and in the trace they are shown as "undefined". Any thoughts to why is this?

推荐答案

下面是一个简单的code,应该工作:

Here is a sample code that should works :

var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, showXML);
// change the path of your php file
xmlLoader.load(new URLRequest("your-file.php"));
function showXML(e:Event):void
{
    var entretenimiento:XML = new XML(e.target.data);
    // for each row :
    for (var x:XML in entretenimiento.loc)
    {
        // Change the name of your tilelist
        myTileList.addItem({label:x.e_nombre, source:x.e_imagen});
    }
}

这篇关于使用PHP和XML有关Flash CS5加载图像从MySQL一个TileList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆