вот мой класс

Код:
package {
import flash.xml.XMLDocument;
import flash.xml.XMLNode;
import flash.xml.XMLNodeType;
import flash.system.System;
class XMLStructure {
static var currentImage:Image = new Image();
static var currentFolder:Folder = new Folder();
static var input_xml = new XMLDocument();
function XMLStructure(xml_document:String) {
var nodeDepth = 0;
XMLNode.prototype.nextNodeTab = function() {
if (this.firstChild != null) {
this.firstChild.attributes.tab = ++nodeDepth;
return this.firstChild;
}
var n = this;
while (n.nextSibling == null) {
if (n.parentNode) {
nodeDepth--;
n = n.parentNode;
} else {
return null;
}
}
n.nextSibling.attributes.tab = nodeDepth;
return n.nextSibling;
};
XMLNode.prototype.nextNode = function() {
if (this.firstChild != null) {
//this.firstChild.attributes.tab = ++_root.nodeDepth;
return this.firstChild;
}
var n = this;
while (n.nextSibling == null) {
if (n.parentNode) {
//_root.nodeDepth--;
n = n.parentNode;
} else {
return null;
}
}
//n.nextSibling.attributes.tab = _root.nodeDepth;
return n.nextSibling;
};
XMLNode.prototype.previousNode = function() {
var n = this;
if (n.previousSibling == null) {
if (n.parentNode) {
n = n.parentNode;
return n;
} else {
return null;
}
}
n = n.previousSibling;
while (n.lastChild != null) {
n=n.lastChild;
}
return n;
};
XMLNode.prototype.get_parentNode = function() {
var n = this;
return n.parentNode;
};
System.useCodePage = true;
input_xml.ignoreWhite = true;// было XMLDocument.prototype.ignoreWhite = true;
input_xml.load(xml_document);
//var intervalID:Number = setInterval(checkProgress, 1, input_xml);
input_xml.onLoad = function(success) {
//clearInterval(intervalID);
//trace("intervalID: "+intervalID);
if (success) {
if (this.status != 0) {
trace("xml - invalid");
} else {
trace("successfull");
this.addAttributes();
this.init();
}
} else {
trace("error opening URL");
}
};
input_xml.addAttributes = function() {
var i = 0;
var nod = this.firstChild;
while (nod) {
nod.attributes.ID = i++;
nod = nod.nextNodeTab();
}
this.parseXML(this.firstChild);
};
input_xml.init = function() {
var nod = input_xml.firstChild;
while (nod.attributes.ID == 0) {
nod = nod.nextNode();
}
if (nod == null) {
trace("no images");
return null;
} else {
currentFolder = nod.parentNode.attributes;
while (nod.nodeName.toUpperCase() != "IMAGE") {
nod = nod.nextSibling;
if (nod == null) {
trace("no images");
return null;
} else {
currentFolder = nod.parentNode.attributes;
}
}
currentImage = nod.attributes;
return currentImage.name;
}
};
}
var checkProgress = function () {
var bytesLoaded:Number = input_xml.getBytesLoaded();
var bytesTotal:Number = input_xml.getBytesTotal();
var percentLoaded:Number = Math.floor((bytesLoaded/bytesTotal)*100);
if (isNaN(percentLoaded)) {
return 0;
} else {
return percentLoaded;
}
};
function nextImage() {
var nod = input_xml.firstChild;
while (nod.attributes.ID != currentImage.ID) {
nod = nod.nextNode();
}
nod = nod.nextNode();
if (nod == null) {
trace("images ends");
return null;
} else {
currentFolder = nod.parentNode.attributes;
while (nod.nodeName.toUpperCase() != "IMAGE") {
nod = nod.nextNode();
if (nod == null) {
trace("images ends");
return null;
} else {
currentFolder = nod.parentNode.attributes;
}
}
currentImage = nod.attributes;
return currentImage.name;
}
}
function previousImage() {
var nod = input_xml.firstChild;
while (nod.attributes.ID != currentImage.ID) {
nod = nod.nextNode();
}
nod = nod.previousNode();
if (nod == null) {
trace("images ends");
return null;
} else {
currentFolder = nod.parentNode.attributes;
while (nod.nodeName.toUpperCase() != "IMAGE") {
nod = nod.previousNode();
if (nod == null) {
trace("images ends");
return null;
} else {
currentFolder = nod.parentNode.attributes;
}
}
currentImage = nod.attributes;
return currentImage.name;
}
}
function get_currentImage() {
return currentImage;
}
function set_currentImage(identificator:Number) {
var nod = input_xml.firstChild;
while (nod.attributes.ID != identificator) {
nod = nod.nextNode();
}
if (nod == null) {
trace("images ends");
return null;
} else {
currentFolder = nod.parentNode.attributes;
while (nod.nodeName.toUpperCase() != "IMAGE") {
nod = nod.nextNode();
if (nod == null) {
trace("images ends");
return null;
} else {
currentFolder = nod.parentNode.attributes;
}
}
currentImage = nod.attributes;
return currentImage.name;
}
}
}
}