Control over index of Foor each loop
I have tried this:
PHP:
<?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"]; echo $path . "#";
}
mysql_close($link);
?>
as3:
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);
}
}
how to have control over the strings in th开发者_运维问答e for each loop?
if you want index too, why not use a regular for loop? it's easier that way, and faster both to code and execute
Edit in response to first comment:
for (var x:int=0; x<ar.length; x++)
{
var i:String=ar[x];
var img:Loader = new Loader();
img.load(new URLRequest(i));
addChild(img);
}
精彩评论