zoukankan      html  css  js  c++  java
  • 用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
  • 相关阅读:
    高精度乘法
    阶乘
    高精度减法
    高精度加法
    曹冲养猪
    采药2
    nginx.conf详解
    系统盘脚本扩容
    IDEA中编写脚本并运行shell脚本
    常用的pdf工具
  • 原文地址:https://www.cnblogs.com/kuailezoe/p/2832789.html
Copyright © 2011-2022 走看看