home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 136
/
MOBICLIC136.ISO
/
pc
/
DATA
/
HOTE
/
prod_gen_JLM
/
moteur.swf
/
scripts
/
__Packages
/
prod
/
moteur
/
V001_ChargementXML.as
next >
Wrap
Text File
|
2011-07-20
|
4KB
|
128 lines
class prod.moteur.V001_ChargementXML
{
function V001_ChargementXML(movieRoot, moduleXmlRoot, moduleOnline)
{
trace("(!) ChargementXML : \r movieRoot : " + movieRoot + "\r moduleXmlRoot: " + moduleXmlRoot + "\r moduleOnline: " + moduleOnline);
this.movieRoot = movieRoot;
this.XmlStocker = new XML();
this.XmlStocker.ignoreWhite = true;
this.XmlStocker.load(moduleXmlRoot);
this.XmlStocker.onLoad = mx.utils.Delegate.create(this,this.onXmlLoaded);
}
function onXmlLoaded(success)
{
trace("(!) onXmlLoaded ");
if(success)
{
this.movieRoot.xmlLoaded();
}
else
{
trace("/!\\ERREUR lors du chargement du fichier xml");
this.movieRoot.debugger.text = "Chargement de fichier xml : ERROR";
}
}
function filterNode(nodePath, attribute, valeur)
{
this.tempNode = new XML();
var _loc3_ = this.recusiveGetNodesByAttribute(this.returnNodeByPath(nodePath),attribute,valeur);
var _loc2_ = this.tempNode.cloneNode(true);
return _loc2_;
}
function returnNodeByPath(nodePath)
{
var _loc4_ = nodePath.split(".");
var _loc3_ = this.XmlStocker.firstChild;
var _loc2_ = 0;
while(_loc2_ < _loc4_.length)
{
_loc3_ = this.getbyNodename(_loc4_[_loc2_],_loc3_);
_loc2_ = _loc2_ + 1;
}
return _loc3_;
}
function returnNodeByPathRandomise(nodePath)
{
var _loc4_ = this.returnNodeByPath(nodePath);
var _loc5_ = new XML();
var _loc6_ = _loc4_.childNodes.length;
var _loc2_ = 0;
while(_loc2_ < _loc6_)
{
var _loc3_ = this.movieRoot.randomValue(0,_loc4_.childNodes.length - 1);
_loc5_.appendChild(_loc4_.childNodes[_loc3_]);
_loc2_ = _loc2_ + 1;
}
return _loc5_;
}
function getbyNodename(nodeName, XMLBlock)
{
var _loc1_ = 0;
while(_loc1_ < XMLBlock.childNodes.length)
{
if(XMLBlock.childNodes[_loc1_].nodeName == nodeName)
{
return XMLBlock.childNodes[_loc1_].cloneNode(true);
}
_loc1_ = _loc1_ + 1;
}
return undefined;
}
function returnNodeByPos(nodePath, nodePos)
{
var _loc2_ = this.returnNodeByPath(nodePath);
return _loc2_.childNodes[nodePos - 1].cloneNode(true);
}
function returnNodeValueByPos(nodePath, nodePos)
{
var _loc2_ = this.returnNodeByPos(nodePath,nodePos);
return _loc2_.firstChild.nodeValue;
}
function getNodeFromNode(node, nodeName)
{
var _loc1_ = 0;
while(_loc1_ < node.childNodes.length)
{
if(node.childNodes[_loc1_].nodeName == nodeName)
{
return node.childNodes[_loc1_].cloneNode(true);
}
_loc1_ = _loc1_ + 1;
}
}
function getNodeByAttribute(node, attribute, attributeValue)
{
this.tempNode = new XML();
this.recusiveGetNodesByAttribute(node,attribute,attributeValue);
if(this.tempNode == null)
{
}
return this.tempNode;
}
function getResourceById(attributeValue)
{
this.tempNode = new XML();
this.recusiveGetNodesByAttribute(this.returnNodeByPath("Resources"),"id",attributeValue);
if(this.tempNode == null)
{
}
return this.tempNode;
}
function recusiveGetNodesByAttribute(node, attribute, attributeValue)
{
var _loc2_ = 0;
while(_loc2_ < node.childNodes.length)
{
if(node.childNodes[_loc2_].attributes[attribute] == attributeValue)
{
this.tempNode.appendChild(node.childNodes[_loc2_].cloneNode(true));
}
if(node.childNodes[_loc2_].hasChildNodes())
{
this.recusiveGetNodesByAttribute(node.childNodes[_loc2_],attribute,attributeValue);
}
_loc2_ = _loc2_ + 1;
}
}
}