OK
After 2 month2 of going online and asking for help and reading every flash book I could get my hands on I have come up with a code that will load .jpg’s from mysql and via filename.
I still do not know how to store the .jpgs in a directory folder name …/images.
This is a major issue with alot of beginners using php,mysql with flash and I am very, very disappointed in the flash forums on the net regarding this isue. Either you get code that is not understandable for beginning-intermmediate folks or for you get tuts that are <snippits> , unclear, or not complete. So here, I will post what I came up with for all to view and use!!!
And it works!!!
This script also fetch the the images in grid rows.
I do not know how to write loops and functions yet so there are alot of if’s statements. If someone wants to consolidate this code please post it!!!
The senario:
10 empty mc’s to hold .jpgs on stage
actionscript
count = 0;
myData = new loadVars();
myData.load(“abc.php”);
myData.onLoad = function(success) {
if (success) {
pic1.loadMovie(this.pic1);
} else {
trace("error: couldn't load from database");
}
};
count = 1;
myData = new loadVars();
myData.load(“abc.php”);
myData.onLoad = function(success) {
if (success) {
pic2.loadMovie(this.pic2);
} else {
trace("error: couldn't load from database");
}
};
count = 2;
myData = new loadVars();
myData.load(“abc.php”);
myData.onLoad = function(success) {
if (success) {
pic3.loadMovie(this.pic3);
} else {
trace("error: couldn't load from database");
}
};
count = 3;
myData = new loadVars();
myData.load(“abc.php”);
myData.onLoad = function(success) {
if (success) {
pic4.loadMovie(this.pic4);
} else {
trace("error: couldn't load from database");
}
};
count = 4;
myData = new loadVars();
myData.load(“abc.php”);
myData.onLoad = function(success) {
if (success) {
pic5.loadMovie(this.pic5);
} else {
trace("error: couldn't load from database");
}
};
count = 5;
myData = new loadVars();
myData.load(“abc.php”);
myData.onLoad = function(success) {
if (success) {
pic6.loadMovie(this.pic6);
} else {
trace("error: couldn't load from database");
}
};
count = 6;
myData = new loadVars();
myData.load(“abc.php”);
myData.onLoad = function(success) {
if (success) {
pic7.loadMovie(this.pic7);
} else {
trace("error: couldn't load from database");
}
};
count = 7;
myData = new loadVars();
myData.load(“abc.php”);
myData.onLoad = function(success) {
if (success) {
pic8.loadMovie(this.pic8);
} else {
trace("error: couldn't load from database");
}
};
count = 8;
myData = new loadVars();
myData.load(“abc.php”);
myData.onLoad = function(success) {
if (success) {
pic9.loadMovie(this.pic9);
} else {
trace("error: couldn't load from database");
}
};
count = 9;
myData = new loadVars();
myData.load(“abc.php”);
myData.onLoad = function(success) {
if (success) {
pic10.loadMovie(this.pic10);
} else {
trace("error: couldn't load from database");
}
};
php script
abc.php
<?php
mysql_connect(“localhost”,"","");
mysql_select_db(“aboy”);
$query = “SELECT * FROM image”;
$result = @mysql_query($query);
$count = "0";
$output = "";
while ($row = mysql_fetch_array($result)) {
$pic = stripslashes($row[‘pic’]);
$pic2 = stripslashes($row[‘pic’]);
$pic3 = stripslashes($row[‘pic’]);
$pic4 = stripslashes($row[‘pic’]);
$pic5 = stripslashes($row[‘pic’]);
$pic6 = stripslashes($row[‘pic’]);
$pic7 = stripslashes($row[‘pic’]);
$pic8 = stripslashes($row[‘pic’]);
$pic9 = stripslashes($row[‘pic’]);
$pic10 = stripslashes($row["pic’]);
$output .= “&pic” . $count . “=” . urlencode($pic);
$output .= “&pic2” . $count . “=” . urlencode($pic);
$output .= “&pic3” . $count . “=” . urlencode($pic);
$output .= “&pic4” . $count . “=” . urlencode($pic);
$output .= “&pic5” . $count . “=” . urlencode($pic);
$output .= “&pic6” . $count . “=” . urlencode($pic);
$output .= “&pic7” . $count . “=” . urlencode($pic);
$output .= “&pic8” . $count . “=” . urlencode($pic);
$output .= “&pic9” . $count . “=” . urlencode($pic);
$output .= “&pic10” . $count . “=” . urlencode($pic);
$count++;
}
echo $output . "&records=" . $count . "&result=Okay&";
?>
like I said if anyone can make the code shorter please do it because the code is really “BIGGGGG”
AND if you know how to target the …/images folder let us know.
As of this date: the files are stored in the same directory as the .swf and .php file
Happy trails
and thank you Eyezburg!!!
C:-)
c now I am happy!!!