AS3: Trying out FDOT
Ted Patrick blogged yesterday that he released the latest build (32) of FDOT, a collection of AS3 classes that are created to make hard things easier to do. I have to say my first use of it did just that, taking an XML import from my normal 2 to 3 custom classes, custom events, etc. down to one basic line with a single method to handle callbacks. It’s hard for me to get out of the habit of using addEventListener’s basically everywhere, but literally within 10 minutes of downloading the latest build of FDOT I was loading in an XML dataset, transforming it to an Array (why? because I like to and it makes sorting easy), and tracing random data from the feed. I will say, I am sold and will be utilizing it whenever I can. Check out the code below, and visit Ted’s site and thank him for making this hard task easy…
You can grab the library here.
You can visit Ted’s blog post here.
Below is a package that I wrote, inspired largely by some of Ted’s sample code. I added a few things that I typically do, like and XML instance and an Array that I will load the XML into. I also for_loop through the XML to added each entry to the Array. Other than that this package is largely identical to Ted’s example, and here for you to use, copy, whatever. Also, below this sample code is the sample XML feed that I am loading, placed in the root of the swf.
package com.connatserdev { import f.net.Load; import flash.display.MovieClip; public class FdotDocClass extends MovieClip { public var testList : XML = new XML(); public var testArray : Array = new Array; public function FdotDocClass() : void { //The heart of the FDOT class, this next line makes the magic happen! Load.xml('test.xml', loadXML, { method:'post', data:{ a:12345 } }); testList.ignoreWhitespace = true; } public function loadXML( event : Object ) : void { if( event.type == Load.COMPLETE ) { //Trace that coolness that was just loaded. trace(event.data); //Set the new XML instance equal to the data that was collected. testList = XML(event.data); //I like placing an xml feed into an array, mainly for the sort feature... for (var i : int = 0;i < testList.slide.length(); i++) { testArray[i] = new Object(); testArray[i].title = testList.*[i].title; testArray[i].path = testList.*[i].path; testArray[i].link = testList.*[i].link; } }else if( event.type == Load.PROGRESS ) { trace(' < loadMovie PROGRESS: ' + event.percent); } } } }
<?xml version="1.0" encoding="UTF-8"?> <slides> <slide> <title>Slide 1 </title> <path>assets/slide01.jpg </path> <link>http://www.connatserdev.com </link> </slide> <slide> <title>Slide 2 </title> <path>assets/slide02.jpg </path> <link>http://www.connatserdev.com </link> </slide> <slide> <title>Slide 3 </title> <path>assets/slide03.jpg </path> <link>http://www.connatserdev.com </link> </slide> <slide> <title>Slide 4 </title> <path>assets/slide04.jpg </path> <link>http://www.connatserdev.com </link> </slide> </slides>

Recent Comments
GarthDB on FlashBuilder: SourceMate AS3Signals Template:
Thanks Brian. I appreciate this being here....
kathryn on I have joined litl!:
psyched to have you onboard! this team just gets more and more awesome....
Filippo on My FlashBuilder 4 color scheme.:
Flash Builder is such a powerful tool, but syntax highlighting just sucks! ...
Devi on AS3: Creating custom events:
This example is awesome...
Josh Molina on AS3: Creating custom events:
Excellent tutorial. Straight and to the point.Thank you.Jo...