Primer on Simply Integration of Domino XML to Flash 6

Mindwatering Incorporated

Author: Tripp W Black

Created: 03/15/2004 at 11:56 AM


Notes Developer Tips

You have Domino-based application that contains dynamic content you wish to rotate like a banner ad on a web page. You have Flash 6 or higher and are comfortable enough with Flash to create a few fields and write a little ActionScript. (ActionScript is pretty much JavaScript with a few twists and some custom objects specific to Flash.)

Other Notes:
For those that have had problems with NotesTimer for Notes Applications and the JavaScript interval lockup then you may want to test this option.

With default settings Internet Explorer caches Flash objects. This means that if the page is reloaded the Flash object does not re-initialize and get any updates to the XML that it uses. A user has to have closed and reopened a web page in order for the Flash object to really reload. For web pages where users leave them open all day, the browser caching settings need to be adjusted.

You can have Flash bring in the XML in various forms:

1. What I call the default "raw" XML produced by a Notes View via ?ReadViewEntries.
You specify this URL and then have your ActionScript read the attributes and update the Flash fields via those attributes. The XML file produced by the ?ReadViewEntries is more complicated & larger, to "mine" than a custom formed one.
2. Have an agent form the XML via looping through a view's entries and using the column values to create the XML. This seems to be slower than option #1. From my limited testing, it also seems to produce a slightly higher server load in drive and processor usage.
3. Create a view whose columns creates the XML entries for that specific entry and embed the view on a page. This proved for me to be the most flexible and seemed to be about the same speed as option #1.

1. Create needed design elements in Designer.
2. Create the Flash SWF to for the web page.
3. Create the web page for the Banner (assuming Domino is hosting the web page to display the Flash banner).

1. Create a view with the XML added to each column formula:
<entry Title="Document Title">This is my body text for this entry</entry>
is created using the column formula ...
"<entry title=\"" + Title + "\">" + @Trim(@Implode(Body; @Char(10)))+ "</entry>"

2. If doing the 3rd option with the page. Create the page. Set the page with an embedded view specifying the view you just created in step #1. Add to the page text for the <entries> parent level above the embedded view and </entries> below the embedded view. Set the web access content type as HTML. If using in Notes set the page to render HTML in Notes. For R5 look for an option for "Treat page contents as HTML" and mark it checked.

The end result if you load this page via browser is:
<entry Title="Document Title">This is my body text for this entry</entry>
<entry Title="A Second Document Title">This is my body text for the second entry</entry>

With a page, you can really do some "cool" tricks.
First, since we're embedding the page, this banner add is limited to 999 entries (assuming you have overridden the default number of lines for the embedded view.) You can choose to only show say the top 10 entries (if sorted in a hidden column by some popularity field) by limiting the number of lines to 10.
Second, since this is Domino, you can reuse the page and view for various types of banner ads throughout a web site assuming the banner ads use the same format (e.g. Title and Body fields). To do this add the sorted categorized column/field and then restrict the embedded view to a specific category that you pass to the view via Query_String mining or use the command line option ?RestrictToCategoy.

1. Create a new Flash project.
2. Size the "set" to the correct width & height.
3. Name the first layer something like "Dynamic Text"
3. Create your fields. Set each one to the dynamic text type. Give each a name. For simplicity's sake, set to the same as the field name in Notes.
4. Create a new layer, named something like "XML ActionScript"
5. Add code similar to the following:
//get xml file
blogs=new XML();
blogs.load("/folderpath/database.nsf/myblog.xml"); // if not on same server make sure you specify complete domain-based URL

//once flash has file loaded it will run this file...
function BlogStart() {
curBlog = blogs.firstChild.firstChild;
NextBlog(); // to make first blog display immediate, do a call now to NextBlog() now before starting the interval
setInterval( NextBlog,4000 ) // 4000 is about 4 seconds. Adjust to your taste

//this function displays current blob and get's next one...
function NextBlog() {
title.text = curBlog.attributes.title;
//loadMovie(curBlog.attributes.clip, placeholder);
body.text = curBlog.firstChild.toString();
// cycle to next blog
curBlog = curBlog.nextSibling;
if (curblog == null) {
curBlog = blogs.firstChild.firstChild;
// test for next blob being nothing, if so loop again ...
if (curBlog.attributes.title == "") {

Save the file. Export the file's SWF and HTML.. We'll need both for step #3.

1. Open or create the form/page to contain the Flash Animation.
2. Import the SWF file into your File Resources.
3. Open up the HTML file created by Flash when the SWF was exported. Paste in the code between the <object> and </object> tags.
4. Mark this pasted text as pass-through HTML.
5. The pasted HTML will assume the SWF is in the same HTML folder as this form/page you are editing. As that is not necessarily true, create ComputedText for each occurrence adding the correct db path. (e.g. "/" + @ReplaceSubString(@ReplaceSubString(@Subset(@DbName; -1); "\\"; "/"); " "; "+") + "/flashfile.swf" ) This way, if the database's name changes in the future, you won't have to remember to update a hard-coded path.
6. Save and view your page in a browser to see your new Domino-XML-Flash enhanced web page!

previous page