PermaLink Using Macromedia Flash with IBM Lotus Domino02/13/2006 05:08 PM
I was looking for a way to display a random photo in a BlogSsphere Block. Instead of writing a LotusScript or Java web agent I decided to to something new (to BlogSphere) also to proof the point that you can use IBM Lotus Domino for almost everything. So I wrote a very small Macromedia Flash file which loads the list of all available photos in a xml format to randomly choose one to display.

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>


This page has been accessed 3323 times. .
Disclaimer
The weblog represent my personal views and comments and does not represent the views of my current or previous employers or customers.

About me
By Category
The BlogRoll
XING advertisement
Proudly Employed By
IBM Lotus Logo
Buy this book
Search
Monthly Archive
2012
2011
2010
2010
2010
2010
2009
2009
2009
2009
2009
2009
2009
2009
2008
2008
2008
2008
2008
2008
2008
2007
2007
2007
2007
2007
2007
2007
2007
2007
2007
2006
2006
2006
2006
2006
2006
2006
2006
2006
2006
2006
2006
2005
2005
2005
2005
2005
2005
2005
2005
2005
2005
2005
2004
2004
2004
2004
2004
2004
2004
2004
2004
2004
2004
2004
2003
2003
Full Archive
Todays Referrers
Advertisement