用xml配置文件加载资源时(XML和XMLList的转换)

<?xml version="1.0" encoding="UTF-8"?>
<root path="resource/">

    <bg path="background.jpg" />
    <hammer uppath="hammer_up.png" downpath="hammer_down.png" />    
    <house buildpath="house_building.png" finalpath="house_final.png" buildtime="3000" />
    <stone buildpath="stonemine_building.png" finalpath="stonemine_final.png" buildtime="5000" />
        
</root>
urlLoader.removeEventListener(Event.COMPLETE,loadCOmhan);
            var rootXml:XML = new XML(urlLoader.data);
            urlLoader = null;
            var rootPath:String = rootXml.@path;
            
            var bgXMLlist:XMLList = XMLList(rootXml.bg);
            var hammerXmllist:XMLList = XMLList(rootXml.hammer);
            var houseXMlList:XMLList = XMLList(rootXml.house);
            var stoneXMllist:XMLList = XMLList(rootXml.stone);
            
            //背景
            var bgXML:XML = XML(bgXMLlist[0]);
            var bgpath:String = bgXML.@path;
            
            //hammer
            var hammerXML:XML = XML(hammerXmllist[0]);
            var hammerUPpath:String = rootPath + hammerXML.@uppath;
            var hammerDownpath:String = rootPath + hammerXML.@downpath;
            var hammerData:HammerVO = new HammerVO();
            hammerData.uppath = hammerUPpath;
            hammerData.downPath = hammerDownpath;
            AssetList.hammerData = hammerData
            
            //house
            var houseXML:XML = XML(houseXMlList[0]);
            var houseData:BuildingVO = new BuildingVO();
            houseData.buildTime = int(houseXML.@buildtime);
            houseData.finalPath = rootPath + String(houseXML.@finalpath);
            houseData.ingPath = rootPath + String(houseXML.@buildpath);
            AssetList.houseData = houseData;
            
            //stone
            var stoneXML:XML = XML(stoneXMllist[0]);
            var stoneData:BuildingVO = new BuildingVO();
            stoneData.buildTime = int(stoneXML.@buildtime);
            stoneData.finalPath = rootPath + String(stoneXML.@finalpath);
            stoneData.ingPath = rootPath + String(stoneXML.@buildpath);
            AssetList.stoneData = stoneData;
urlLoader.removeEventListener(Event.COMPLETE,loadCOmhan);
            var rootXml:XML = new XML(urlLoader.data);
            urlLoader = null;
            var rootPath:String = rootXml.@path;
            
            var bgXMLlist:XMLList = XMLList(rootXml.bg);
            var hammerXmllist:XMLList = XMLList(rootXml.hammer);
            var houseXMlList:XMLList = XMLList(rootXml.house);
            var stoneXMllist:XMLList = XMLList(rootXml.stone);
            
            //背景
            var bgXML:XML = XML(bgXMLlist[0]);
            var bgpath:String = bgXML.@path;
            
            //hammer
            var hammerXML:XML = XML(hammerXmllist[0]);
            var hammerUPpath:String = rootPath + hammerXML.@uppath;
            var hammerDownpath:String = rootPath + hammerXML.@downpath;
            var hammerData:HammerVO = new HammerVO();
            hammerData.uppath = hammerUPpath;
            hammerData.downPath = hammerDownpath;
            AssetList.hammerData = hammerData
            
            //house
            var houseXML:XML = XML(houseXMlList[0]);
            var houseData:BuildingVO = new BuildingVO();
            houseData.buildTime = int(houseXML.@buildtime);
            houseData.finalPath = rootPath + String(houseXML.@finalpath);
            houseData.ingPath = rootPath + String(houseXML.@buildpath);
            AssetList.houseData = houseData;
            
            //stone
            var stoneXML:XML = XML(stoneXMllist[0]);
            var stoneData:BuildingVO = new BuildingVO();
            stoneData.buildTime = int(stoneXML.@buildtime);
            stoneData.finalPath = rootPath + String(stoneXML.@finalpath);
            stoneData.ingPath = rootPath + String(stoneXML.@buildpath);
            AssetList.stoneData = stoneDa
posted on 2012-12-25 17:30  橙小风  阅读(598)  评论(0编辑  收藏  举报