var myVars:LoadVars = new LoadVars();
myVars.sendAndLoad("flash.php", myVars, "POST");
myVars.onLoad = function(){
trace(myVars.totalr);
}
That should work as long as the php is working and they are in the same folder
BTW:
I even set the php to just echo “totalr=3”
with quotes or without?
Like defective said, they’re are definitely more robust / effecient ways of doing this, especially if your gallery contains hundreds of images. However, if you change the echo string in your php to this - I’m just eliminating the double quotes from the string passed from php:
echo 'pic'.$x.'=gallery/'.$pic.',gallery/'.$thumb.'&';
then you can use the following to formulate the array, if this is a small gallery and this works, I’d say use it if you’re in a rush. But it will be worthwhile to build on / edit this if you want this to be something thats really efficient and reusable (that pretty much goes without saying I guess when questions are answered on these forums
)
[AS]
var objArray:Array = [];
var loadV:LoadVars = new LoadVars();
loadV.onLoad = function() {
for(var i in this) {
//a quick filter to grab all props of the loadVars that aren’t built-in methods
if(i.substr(0,3)==“pic”) {
var tempArray:Array = this*.split(",");
var tempObject:Object = {img:tempArray[0],thumb:tempArray[1]};
objArray.push(tempObject);
}
}
// this will trace all the objects, you can delete this later:
var len:Number = objArray.length;
for(var j:Number=0; j<len; j++) {
trace(objArray[j]+" = "+objArray[j].img+ " & "+objArray[j].thumb);
}
// you'd place your
// mygallery.createFromArray(objArray);
// call here - asl long as all of this code is on frame in the main timeline vs. an AS2 Class
}
var phppath:String = “pathtoyourphpfile.php”;
loadV.load(phppath);
[/AS]
shoot guys - sorry - I didn’t see all of the work on page two of this thread, hope it all worked out!
cr --> dude ill try your solutions also man…thansk again so much
def --> so the output look like totalr=3
Creat --> ive gotten furtehr with your method at the moment man …the gallery actually gets closer to loading buthis is shown in the out put window:
[object Object] = gallery/’.$pic.’ & undefined
Loading ERROR CODE = URLNotFound
Unable to connect to URL: file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/’.$pic.‘
Error opening URL "file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/’.$pic.’"
Seems like somehow the php is gettin sucked into flash …but all that displays in a browser window is the string?!
this is in the path to your php doc?
The%20Phoenix%20Rose%20Admin/gallery/
path to php doc: localhost/the phoenix rose admin/ (php doc and flash here)
path to images:localhost/the phoenix rose admin/gallery
Loading ERROR CODE = URLNotFound
Unable to connect to URL: file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/’.$pic.‘
Error opening URL "file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/’.$pic.’"
PS suspect those errors are out put from the component!
This is the output when i try moving the ampersand to the START of the string:
[object Object] = gallery/’.$pic.’ & gallery/’.$thumb;
$x ;
}
?>
Error opening URL "file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/’.$thumb;
$x ;
}
?> “
Loading ERROR CODE = URLNotFound
Unable to connect to URL: file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/’.$pic.‘
Error opening URL "file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/’.$pic.’”
Hope this isnt annoying but here’s something else ive tried on the php side:
<?
include ('functions.php');
$sql= "SELECT * FROM gallery";
$query = mysql_query($sql);
$total = mysql_num_rows($query);
$x=1;
$string = "&";
while ($result = mysql_fetch_array($query)){
$pic = $result['picture'];
$thumb= $result['thumbnail'];
$string .= 'pic'.$x.'=gallery/'.$pic.',gallery/'.$thumb;
$x++;
}
$string .= "&";
echo $string;
?>
[/]php]
This results in no visible out put at all!
we’ve all been there, trying to get a project done and nothing but error after error, its frustrating
yeah, it seems to me that the php isn’t working right - I just don’t know enough about php to be much help. The errors seem to show that the php isn’t returning the proper names of the images - I’m guessing all your images are non-progressive jpgs?
conclusion: sumthing to do with the / behind gallery …ithink?
But I got no idea how to deal with it!
sorry bro didnt see your reply …yeah i dont think its a problem with the images. When i use the outputed string in a static file tha gallery works a charm!
defec --> any clue what could be goin on PHP side her man?
even odder:
<?
/*
include ('../Connections/tpr.php');
$sql= "SELECT * FROM gallery";
$query = mysql_query($sql);
$total = mysql_num_rows($query);
$x=1;
while ($result = mysql_fetch_array($query)){
$pic = $result['picture'];
$thumb= $result['thumbnail'];
echo "&pic".$x."=gallery/".$pic.",gallery/".$thumb;
$x++;
}
*/
echo "&pic1=Sunset.jpg,tSunset.jpg&pic2=Winter.jpg,tWinter.jpg&pic3=Sunset.jpg,tSunset.jpg";
?>
Even with the code commented out …and on the plain var string put out i get these errors:
[object Object] = Sunset.jpg & tSunset.jpg";
?>
[object Object] = Winter.jpg & tWinter.jpg
[object Object] = Sunset.jpg & tSunset.jpg
[object Object] = gallery/".$pic." & gallery/".$thumb;
$x ;
}
*/
echo "
Error opening URL "file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/tSunset.jpg";
?> "
Error opening URL "file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/gallery/".$thumb;
$x ;
}
*/
echo ""
crit -> dude i think this may have something to do with the way your spliting the string is your code.
when i change this*.split(","); to this*.split("&");
there are still errors but they look closer to the mark:
[object Object] = Sunset.jpg,tSunset.jpg";
?> & undefined
[object Object] = Winter.jpg,tWinter.jpg & undefined
[object Object] = Sunset.jpg,tSunset.jpg & undefined
[object Object] = gallery/".$pic.",gallery/".$thumb;
$x ;
}
*/
echo " & undefined
Loading ERROR CODE = URLNotFound
Unable to connect to URL: file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/Sunset.jpg,tSunset.jpg";
?>
Error opening URL "file:///E|/EasyPHP1%2D8/www/The%20Phoenix%20Rose%20Admin/gallery/Sunset.jpg,tSunset.jpg";
?> "
[/as>
based on this output string:
&pic1=Sunset.jpg,tSunset.jpg&pic2=Winter.jpg,tWinter.jpg&pic3=Sunset.jpg,tSunset.jpg
Well,
I fixed my problem by setting my CMS to simply write the xml file using fopen when a picture is uploaded…so wish id done this earlier!