Forums: Flash:

 

Photo Browser flash+xml+php

first 2 3 last
 

craftymind Photo Browser flash+xml+php

I thought you guys might get a kick out of this.

http://www.mustardlab.com/developer/test/new/

The directory includes the following files you can download if you want

gallery.fla
gallery.swf
gallery.php
index.php

**jpg images

what happens is the swf file loads in gallery.php which contains the following code


<?
$xml = '<?xml version="1.0"?'.'>';
$handle = opendir(".");
while ( ($file=readdir($handle)) !== false ) {
if ( !is_dir($file) ){
$pic = @getimagesize($file);
if($pic != false && $pic[2] == 2){
$xml .= '<img src="'.$file.'" width="'.$pic[0].'" height="'.$pic[1].'" />';
}
}
}
echo $xml;
?>


which spits out an xml list of every image in the folder gallery.php is included in


<?xml version="1.0"?>
<img src="animal.jpg" width="466" height="548" />
<img src="just_married.jpg" width="389" height="578" />
<img src="richard_mackson.jpg" width="473" height="316" />
<img src="sinister.jpg" width="480" height="360" />
<img src="st_helens.jpg" width="479" height="480" />
<img src="superdog.jpg" width="500" height="339" />


the index page lets you even link to a specific image
http://www.mustardlab.com/developer/test/new/?image=sinister.jpg

which is taken care of by some code in the index.php file

<param name="FlashVars" value="<? if(isset($_GET['image'])) echo "topimage=".$_GET['image'] ?>" />


all the source code is in http://www.mustardlab.com/developer/test/new/gallery.fla

I have to admit though, the visual idea of a photostack has to be credited to Andy from trendwhore.net if any of you are on there, he was also andy on o8. I just tried to make it as fast and seamless as possible

 

jeremy

not worthy
amazing


*was that the jmack dog in there too?

 

craftymind

jmack dog smile ?

i think this would be more his breed.

 

Barn

I don't know anything about PHP, but I'd love to look at those PHP files. How can I get at them? (Got the FLA, but can't figure out a way to download the PHP files.)

I have abandoned this haven of asshole smokers
quote
 

craftymind

this is the entire contents of gallery.php


<?
$xml = '<?xml version="1.0"?'.'>';
$handle = opendir(".");
while ( ($file=readdir($handle)) !== false ) {
if ( !is_dir($file) ){
$pic = @getimagesize($file);
if($pic != false && $pic[2] == 2){
$xml .= '<img src="'.$file.'" width="'.$pic[0].'" height="'.$pic[1].'" />';
}
}
}
echo $xml;
?>


and the entire code for index.php

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<title>Flash Photo Stack</title>
</head>
<body style="margin:0px">
<object id="flashmovie" type="application/x-shockwave-flash" data="gallery.swf" width="100%" height="100%">
<param name="movie" value="gallery.swf" />
<param name="FlashVars" value="<? if(isset($_GET['image'])) echo "topimage=".$_GET['image'] ?>" />
</object>
</body>
</html>


sorry, the server will process these files so there's no way of downloading the raw text unless I upload it into a .txt file on the server.

 

craftymind

i should just make this easier smile

http://www.mustardlab.com/developer/test/new/gallery.zip

 

persist

it's fun to clickreally really fast.

nice stuff!

 

craftymind

I optimized the code entirely around the ability to click immediately even without all the images loaded and clicking any list size of photos as fast as possible.

 

sakri

sweet!!!11

I had the php converting to xml thing before, but I love the photostack thing (even if the credits go to some guy named andy from some place called o8 big grin)

now make a recursive function that goes through all sub folders etc. and creates a deep nested xml tree :nerd:

ThumbsUp

---- ----
________________________________________________________
__________________________________________________________________
quote
 

mosquito

very nice crafty!

The significant problems we face cannot be solved by the same level of thinking that created them. - Albert Einstein
quote
 

Flux

Great!! I'm gonna use that PHP a lot thanks!!

 

shuteye

$pic[2] == 2


Maybe a dumb question, but I don't get this part. So pic[0] is width, pic[1] is height, but why pic[2] ==2?

A high standard of standardness.





quote
 

mosquito

getimagesize($file)

Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 is a flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM. These values correspond to the IMAGETYPE constants that were added in PHP 4.3. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag.
in short it if there is a return and it is of type jpg, do this...
*runs*

The significant problems we face cannot be solved by the same level of thinking that created them. - Albert Einstein
quote
 

shuteye

But why read for myself when i have all these helpful people to tell me stuff? smile

A high standard of standardness.





quote
 

mosquito

i'm just giving you a hard time. i'm suprised you haven't dug into php yet. it's a blast.

The significant problems we face cannot be solved by the same level of thinking that created them. - Albert Einstein
quote
 

craftymind

i was considering using this for that 100 lines of AS contest we were going to have for loading data, but I'm assuming that contest is dead?

 

mosquito

it's not dead yet, i think we just all got really busy. i keep thinking about it though.

smile

The significant problems we face cannot be solved by the same level of thinking that created them. - Albert Einstein
quote
 

persist

also, we were going to coincide it with the v2 launch.

 

craftymind

ok.

btw, in case anyone is wondering what this code does


MovieClip.prototype.addProperty("onLoad", function () {
return __onLoadHandler__[this];
}, function (f) {
if (__onLoadHandler__ == undefined) {
_global.__onLoadHandler__ = {};
}
__onLoadHandler__[this] = f;
});


I can't remember where I got it from, but it restores the onLoad handler for movieclips when loading jpgs and swfs, very handy when you don't need or want to set up a getBytesLoaded/getBytesTotal loader

I'm assuming everyone is aware that flash wipes out all variables and values of a clip when loading files into that clip, but I guess flash doesn't reset or wipe out properties overridden or added through addProperty.

 

persist

can you share a simplified example usage?

 
first 2 3 last
 

Forums: Flash: Photo Browser flash+xml+php

 
New Post
 
You must be logged in to post