Posts Tagged ‘flash’

Loading XML with ActionScript and Arbol Negro

Thursday, May 27th, 2010

One of the most common task in actionscript in loading XML, it is the native way to load complex data; but there is a time when this process become a little anoying, because as you remember, in as2, load XML was just a couple of lines; in as3 is not that hard, but there are a couple of separate steps to load it and it’s sometimes confusing for begginers.

I have created XMLHandler to carry on those repetitions to “the easy way”, here is an example:

import flash.display.MovieClip;
* ...
* @author Sebastián Sanabria Díaz
public class Main extends MovieClip

private var _xmlHandler:XMLHandler
public function Main()
_xmlHandler = new XMLHandler();
_xmlHandler.addEventListener(Event.COMPLETE, onCompleteXMLHandler);
_xmlHandler.addEventListener(ProgressEvent.PROGRESS, onProgressEvent);
_xmlHandler.path = "data.xml";

private function onProgressEvent(e:ProgressEvent):void
trace(e.bytesLoaded / e.bytesTotal);

private function onCompleteXMLHandler(e:Event):void
{, onCompleteXMLHandler);
//trace(;//using event parameter
trace(_xmlHandler.xml);//using the private var



This is a very simple example, loads XML, traces it, also shows its progress, which in a bigger XML file will be more useful.

Download example files:

The Arbol Negro Project

Tuesday, May 25th, 2010

Hi, my name is Sebastian Sanabria-Diaz, I’m a developer and today I wish to share under the GPL3 License, the actionscript3 code on wich I’ve been working and believe will help to many people who develop for Flash ActionScript3.

The general purpose of this project is to raise the level of skills, removing some repetitive work, sometimes removing simple steps, but too a big amount of repetitive steps and putting all into a single class.

There is XMLHandler wich handles a bit easier XML, joining a couple of steps into a single one, handling too events and errors.

Also CircularList wich is an endless-Array with features like: paging, to easy create a gallery.

Today may 25 I’m presenting a piece of this project, it is not complete, there is a lot more comming, but for reasons of time, I havent cleaned it completely; also is not completely documented, so first I’ll show examples before upload a full documented code.

Try the code, you can comment, if you consider that something is missing you can tell me, report error or bugs, you can do it here, or at the google project main page.


Go to Arbol Negro at Google Code

Switch to our mobile site