2011-10-11 77 views
0

我已经填充了一个php页面,我在该php中拉图像。现在我怎么可以通过数组将这些图像放入Flash中。 PHP代码是发送图像从PHP到Flash

<?PHP 

$link = mysql_connect("localhost","root",""); 
mysql_select_db("dbname"); 

$query = "SELECT * FROM dress where dress_type='shirts' AND sex='male'"; 
$results = mysql_query($query); 

while($row = mysql_fetch_assoc($results)) 
      { 
       $path = $row["imagelocation"]; 
       $final = "<img src='$path' width='100' height='100'>\n"; 
       echo "$final"; 
} 



mysql_close($link); 

?> 

回答

0

变化:

$path = $row["imagelocation"]; 
$final = "<img src='$path' width='100' height='100'>\n"; 
echo "$final"; 

要这样:

$path = $row["imagelocation"]; 
echo $path . "#"; 

这样你得到一个哈希分隔的所有图像路径的列表。

然后,当你加载PHP文件,你就可以创建你的所有图像路径的数组:

var ldr:URLLoader = new URLLoader(
    new URLRequest("your_php_file.php") 
); 

ldr.addEventListener(Event.COMPLETE, _done); 
function _done(e:Event):void 
{ 
    ldr.removeEventListener(Event.COMPLETE, _done); 

    var ar:Array = String(e.target.data).split("#"); 

    for each(var i:String in ar) 
    { 
     var img:Loader = new Loader(); 
     img.load(new URLRequest(i)); 

     addChild(img); 
    } 
} 
+0

它不会为我工作。我也必须展示图像。你可以帮我吗? –

+0

我拥有的代码应该显示图像 - 您需要用您的PHP脚本的URL替换'your_php_file.php'。 – Marty

+0

它可以显示图像。但图像是重叠的。我该怎么办? –