December 06, 2003
'googLinks' updated, code sample
I updated my 'googLinks' on the main page to pull the .opml files from my own site instead of getting them from Full as a Goog. I also thought I'd post the code I'm using with the new Tree component in Flash MX 2k4 Pro. It's pretty straightforward, and hopefully my comments will help you understand it a little better...
var categories : Array = ["Central", "ColdFusionMX", "DreamweaverMX", "FlashMX", "WebBuilder"]; var current : Number = 0; var today : Date = new Date(); var path : String = "/googLinks/"; var cacheBuster : String = "?rand=" + today.getDay(); // single XML variable re-used for every category var loader : XML = new XML(); loader.ignoreWhite = true; loader.onLoad = function(success) { if (success) { // add the head to the tree var header = new XML().createElement("node"); header.attributes.label = categories[current]; header.attributes.icon = categories[current]; // keep a reference to the head when we add it var treeData = googLinks.addTreeNode(header); // declare an array to hold all of the links // -- used to sort the entries var dataHolder = new Array(); // populate the array with all of the info from the outline // tags in the .opml files. var body : XMLNode = this.firstChild.firstChild.nextSibling; var outline = body.firstChild; while (outline != null) { dataHolder.push({label:outline.attributes["title"], data:outline.attributes["id"]}); outline = outline.nextSibling; } // sort the array, then add the nodes under the head via the // 'treeData' reference we created above dataHolder.sortOn("label", Array.CASEINSENSITIVE); for (var i = 0; i < dataHolder.length; i++) { treeData.addTreeNode(dataHolder[i].label, dataHolder[i].data); } // load the next category if we need to if (current < categories.length - 1) { current++; loader.load(path + categories[current] + ".opml" + cacheBuster); } else { // nothing else to load... clean up! delete loader; delete current; delete categories; delete today; delete path; delete cacheBuster; } } } // start the ball rolling with the first load loader.load(path + categories[current] + ".opml" + cacheBuster); // set up the tree style _global.style.setStyle('themeColor', 'haloOrange'); googLinks.setStyle('selectionColor', 0xFFFFFF); googLinks.setStyle('rollOverColor', 0xD8D8D8); googLinks.setStyle('fontFamily', 'Verdana'); googLinks.setStyle('fontSize', 9); googLinks.rowHeight = 24; // delcare an icon function to place the icons. by // default I look for the "icon" attribute, and if not // there, use the 'Bullet' icon. Every icon has a // movieClip symbol in the library with its linkage // name set to the icon name. googLinks.iconFunction = function (node) { var ico = node.attributes.icon; if (ico == undefined) { ico = 'Bullet'; } return ico; } // old school, just declare a changeHandler instead // of adding an event listener. googLinks.changeHandler = function () { // open up the site if there is a URL if (this.selectedNode.attributes.data != undefined) { getURL(this.selectedNode.attributes.data); } else { // no URL, so that means they clicked on a // category head. if the category is open, // close it, otherwise open it. the last "true" // param is for playing the transition so the // the category doesn't just "snap" open or closed this.setIsOpen(this.selectedNode, !this.getIsOpen(this.selectedNode), true); } }
Enjoy your weekend! I'll be out playing in the snow. We got hit with around 8 inches overnight here in eastern Pennsylvania... woohoo for the first snow of this winter season! Snowboarding anyone?

Comments
Thanks for the script! I think it can be quite useful to me. I'm really planning to use it in one of my project. thx again!
Posted by: Pussy Cat at January 19, 2004 02:44 AM
Oh yeah, I forgot - it's me, Sandra :)
--
Sandra @ http://www.pussy-cats.org
Posted by: Pussy Cat at January 21, 2004 12:26 AM
Yeeeahd, it's csool
Posted by: Numit at February 21, 2004 06:54 AM
dear Sir / hi
please help me to build true form with flash & asp.net
best regards
mahdi reda sayed
Posted by: mahdi at August 17, 2005 04:50 AM