First you have to publish your data in a Flash compatible way. The output should look like this:
<gallery>
<image title="DSCF0139" main="http://chris.brandlehner.at/Brandlehner/cab_blog.nsf/pictures/CBRR-6EJDEA/$file/TN_CBRR-6EJDEA.jpg" url="http://chris.brandlehner.at/Brandlehner/cab_blog.nsf/pictures/CBRR-6EJDEA"/>
<image title="DSCF0135" main="http://chris.brandlehner.at/Brandlehner/cab_blog.nsf/pictures/CBRR-6EJDE5/$file/TN_CBRR-6EJDE5.jpg" url="http://chris.brandlehner.at/Brandlehner/cab_blog.nsf/pictures/CBRR-6EJDE5"/>
</gallery>
To create this xml file create a view first. The views name is "xmlphotos".
The views selection formula is "SELECT ( Form = "Picture" & Photo_Thumb_FileName!= ""& (!@Contains(delete; "1")) & !@Contains(PhotoStatus; "Private"))"
Have one column with the formula ""<image title=\"" + Subject + "\" main=\"" + ShortURL + "/pictures/" + Permalink + "/$file/" + Photo_Thumb_FileName + "\" url=\"" + ShortURL + "/pictures/" + Permalink + "\"/>""
Now create a page named "xmlphoto.xml".
Create a computed text field with the formula "@SetHTTPHeader("Expires";@Adjust(@Now([ServerTime]);0;0;0;1;0;0));""". This field is used for caching to reduce unnecessary traffic to your site.
Embed the view xmlphotos and add the gallery tag before and after the view.
Change the pages Mimetype to text/xml.
Now you are ready for the first test. You should see a result similar to this page if you access that page using a web browser: http://chris.brandlehner.at/Brandlehner/cab_blog.nsf/xmlphoto.xml
Create a new file in Macromedia Flash and save it as RandomPhoto.fla.
In the first Keyframe add the following ActionScript which will load the xml data.
stop();// stop in this Frame (1)
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
numimages = this.firstChild.childNodes.length;
gotoAndStop(2); //continue with Frame 2
};
myPhoto.load("xmlphoto.xml");
Add a second KeyFrame and add this ActionScript:
function randomBetween(min, max) {
return (min+Math.floor(Math.random()*(max-min+1)));
}
var rand = randomBetween(0, numimages-1);
mc = _root.createEmptyMovieClip("container", 1);
mc.createEmptyMovieClip("photo", 1);
container.photo.loadMovie(myPhoto.firstChild.childNodes[rand].attributes.main);
container.onPress = function() {
getURL(myPhoto.firstChild.childNodes[rand].attributes.url, "_top");
};
Save this file (RandomPhoto.fla) and export it to RandomPhoto.swf.
Last step is to embed the RandomPhoto.swf on you website.
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="150" HEIGHT="150" id="RandomPicture" ALIGN="">
<PARAM NAME=movie VALUE="RandomPicture.swf">
<PARAM NAME=loop VALUE=false>
<PARAM NAME=quality VALUE=high>
<PARAM NAME=wmode VALUE=transparent>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="RandomPicture.swf" loop=false quality=high wmode=transparent bgcolor=#FFFFFF WIDTH="150" HEIGHT="150" NAME="RandomPicture" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED></OBJECT>