eager_to_learn
asked on
How to display a php image array in different flash uiloaders
I am stuck on the following problems:
Problem 1:
How do I display a php array of blob images in multiple flash uiloaders using as3?
Php Code:
Problem 2:
The php file above returns an array so I am assuming I don't need to convert but my assumptions are probably wrong. How can I load the data from the php code to my as3 code?
AS3 Code:
Problem 1:
How do I display a php array of blob images in multiple flash uiloaders using as3?
Php Code:
<?php
//connected to database
//Selecting the Table
$sql = "SELECT IMG FROM Product";
$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
mysql_close($link);
//Loop through the IMG column in the Product table
while ($display = mysql_fetch_array($result, MYSQL_ASSOC)) {
$show = $display["IMG"];
//code allows the image to display
header("Content-type: image/png");
echo $show;
}
?>
Problem 2:
The php file above returns an array so I am assuming I don't need to convert but my assumptions are probably wrong. How can I load the data from the php code to my as3 code?
AS3 Code:
var imagePHP:String = "/scripts/imgView.php";
var subLoad:URLRequest = new URLRequest(imagePHP);
var mainLoad:URLLoader = new URLLoader(subLoad);
mainLoad.addEventListener(Event.COMPLETE, done);
function done(e:Event):void
{
for(var i = 0; i < count; i++) {
//7 UILoaders to hold the first 7 images from database
Product1.load(mainLoad[i]);
Product2.load(mainLoad[i]);
Product3.load(mainLoad[i]);
Product4.load(mainLoad[i]);
Product5.load(mainLoad[i]);
Product6.load(mainLoad[i]);
Product7.load(mainLoad[i]);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Solution found by requester
I do things like this using AMF and sending multiple byte-Arrays containing the image data. In ActionScript I get an Array of ByteArrays. I manually create one Image for each ByteArray and set the source property of the Image to one of these ByteArrays.
Works great.