Using Flash to display data from SharePoint

I have receiving some emails lately about a post I did re a small project I did a few years ago way back in 2005 where I developed a US map in Flash that aggregated data from a list of regional sales entries stored in SharePoint. 
 
Essentially everything is done in actionscript calling the owssrv.dll ISAPI extension to retrieve the data in XML format via XMLHTTP.  Funny my co-workers looked at me funny back then when I suggested maybe developing client-side web-parts might be a good idea for working with SharePoint in some simple scenarios-they are not looking funny at this anymore with Web 2.0 these days:)  Anyway, more recently I have been calling the list.asmx web service for this type of thing but I managed to dig up this old project and it still works and figured I would share.  No warrantees. 
 
map
To get this set-up yourself and improve it all you need is a place to create a SharePoint list with two fields: Region and Amount.  Region values are East, West, and Central and is a choice field.  Amount is a number type. 
 
Then fire up the attached Map.fla file, modify the parameters in the actionscript to call your particular list i.e. site URL and List GUID.  Lastly publish the file to HTML and then upload the fla and swf files into a SharePoint document library.  I used a CEWP and copied the HTML from the mapnew.html I had created being careful to edit this file to use the full path to the map.swf file in the doc library where I uploaded to.  Then you can place the CEWP on any site page in the site collection-maybe elsewhere I am not sure. 
 
 

One thing to watch out for is security settings for Flash have been updated a bit since I did this initially so I had to to allow Flash to access data from the internet making my SharePoint site trusted.  The link is in the security settings text file in the Flash Map folder.

 
Have fun:)  Rod.

How to pull Sharepoint list data into Flash using actionscript/XMLHTTP

I developed this as part of a project to retrieve and aggregate data from a sharepoint list and display in fields on a regional map of the US using flash for the UI.  This was in Sharepoint 2003 but will work in 2007 as well. 
 
The basic premise is to use XMLHTTP to obtain the data from your Sharepoint list, from Flash use the XML object in Actionscript to load the response XML and then parse through the XML using the XML DOM. 
 
 
//*****Begin configuration area **************
//*******General Configuration (Required for both portal and team sites**************
//change siteBaseURL to Sharepoint site URL
siteBaseURL = "http://[serveraddress]";
//valid values are portal or team
siteType = "team";
//List Id configuration
//update listid to appropriate list id in sharepoint
//to locate list id browse to sharepoint list and select modify columns/settings and
//copy listid from URL
 //change listId to image list GUID
listId = "{[listguid]}";
//*********Team Site Specific Configuration(Required for teamsites only************
//change site to site name in URL
site = "[sitename]";
 //*****End configuration area **************
//switch for whether this is a team or portal site to obtain the correct URL 
 if(siteType == "team")
 {
   GetURL = siteBaseURL + "sites" + "/" + site + "/_vti_bin/owssvr.dll?Cmd=Display&List=" + listId + "&XMLDATA=TRUE";
 }
 else
 {
   //GetURL = "";
 }
 if(siteType == "portal")
 {
   GetURL = siteBaseURL + "_vti_bin/owssvr.dll?Cmd=Display&List=" + listId + "&XMLDATA=TRUE";
 }
 else
 {
  }
myXML = new XML();
myXML.load(GetURL);
myXML.ignoreWhite = true;
myXML.onLoad=extractData;
function extractData(success){
rootNode = this.firstChild;
oNodeList = rootNode.childNodes;
wArray = new Array();
eArray = new Array();
cArray = new Array();
for(i = 0; i < oNodeList.length; i++)
 {
  rsnode = oNodeList[1];
 }
  
zNodeList = rsnode.childNodes;
 //sum attachment nodes
 
 for(i = 0; i < zNodeList.length; i++)
 {
  zNode =  zNodeList[i];
  
  if(zNode.attributes.ows_Region == "West")
  {
   attr = parseFloat(zNode.attributes.ows_Amount);
   num = new Number(attr);
   wArray[i] = num;
  }
  
  if(zNode.attributes.ows_Region == "East")
  {
   attr = parseFloat(zNode.attributes.ows_Amount);
   num = new Number(attr);
   eArray[i] = num;
  }
  
  if(zNode.attributes.ows_Region == "Central")
  {
   attr = zNode.attributes.ows_Amount;
   num = new Number(attr);
   cArray[i] = num;
  }
      
  }
_root.westText.text = FormatAsDollars(sumAttributes(wArray));
_root.centralText.text = FormatAsDollars(sumAttributes(cArray));
_root.eastText.text = FormatAsDollars(sumAttributes(eArray));
function sumAttributes(aArray)
{
 tNum = new Number();
 for(x = 0; x < aArray.length; x++)
 {
  xNum = new Number(aArray[x]);
  tNum = tNum + xNum;
 }
 return tNum;
   
}
 
function FormatAsDollars (amount, isCents) {
//
// Make sure we’re given a real number to work with: 
   if (isNan(amount)) {
     return NaN;
   }
//
// Convert everything to cents. A float is assumed to be
// dollars-and-cents, while an integer is assumed to be in
// dollars unless an "isCents" argument is added to the call. 
   if (isCents != "isCents") {
     amount = amount*100;
     amount = Math.round(amount);
   }
//
// Handle less-than-a-dollar single-digit and double-digit cases:  
   amount = String(Math.floor(amount));
   if (amount.length == 1) {
     return ("0.0"+amount);
   }
   if (amount.length == 2) {
     return ("0."+amount);
   }
  
//
// First grab the last two characters as cents, and remove them
// from the amount string:
   cents = amount.slice(-2);
   amount = amount.substring(0, amount.length-2);
//
// Now stuff the last three digits at a time into an array, removing
// them from the string. (We have to work backwards to figure where
// commas should go.)
   dollars = [];
   do {
     dollars.push(amount.slice(-3));
     amount = amount.substring(0, amount.length-3);
   } while (amount.length>3);
//
// If there are 1 or 2 numbers remaining, they’ll need to be at
// the front of the number, with their own comma. (We need to test
// to make sure we don’t end up with $,123.00 or such.)  
   if (amount.length) {
     dollars.push(amount);
   }
//
// Now reverse the array, so the last elements appear first:  
   dollars.reverse();
//
// Finally construct the return string. The "join()" function turns
// an array to a comma-delimited string.  
   //return ("$"+ dollars.join() + "." + cents);
   //modify to format return format output
   return (dollars.join());
}
}
//author Rod Stagg January 2005