从AS3中的XML中删除重复的enteries / items

时间:2015-04-29 16:13:26

标签: xml actionscript-3 flash actionscript

我从XML文件中获得了重复的结果。我想删除多余的,但使用spliceindexOf无法实现此目的。有人能指出我正确的方向吗?

var xmlLoader:URLLoader = new URLLoader();
var xmlReq:URLRequest = new URLRequest("data.xml");

xmlLoader.load(xmlReq); 

var background:bkg;  var textvar:TextField = new TextField;         
xmlLoader.addEventListener(Event.COMPLETE, convertdata);

function convertdata(event:Event){  
    var xmlinfo:XML = new XML(event.target.data);   
    //trace(xmlinfo);


    var list:XMLList = xmlinfo.profile.photography;

    var totalimage:Number = list.length();

    trace("length " + totalimage);

    enterbtn.addEventListener(MouseEvent.CLICK, entersite);

    function entersite(event:MouseEvent){
        for (var i:int =0; i<totalimage; i++){
            trace(xmlinfo.profile.photography[i]);

            background = new bkg();
            background.y = i*40;
            background.x =80;
            addChild(background);

            textvar = new TextField();
            textvar.text = list[i];    
            background.addChild(textvar);
        }

    }   
}

XML文件

        <profile>
            <first_name>ann</first_name>
            <last_name> lee</last_name>
            <photography>sport</photography>
            <photography>landscape</photography>
            <photography>still life</photography>           
            <image>img1.jpg</image>

        </profile>

        <profile>   
            <first_name>john</first_name>
            <last_name> thomas</last_name>
            <photography>wildlife</photography>
            <photography>landscape</photography>
            <image>img2.jpg</image>
        </profile>

0 个答案:

没有答案