<lists> <list category="WORDSONE"> <word>SHOW</word> <word>WHICH</word> <word>EVERYTHING</word> <word>LOVE</word> <word>ROUND</word> <word>STRONG</word> <word>DUCK</word> <word>SKIN</word> </list> </lists>
连接的内容是:
doc = new XML(); doc.ignoreWhite = true; doc.load("wordlists.xml");
接着是分配
function myHandler() { playButton._alpha = 100; playButton.enable = true; var _l1 = scrollList.getSelectedItem().data; words.words = words.lists[_l1].wordList; words.category = scrollList.getSelectedItem().label; } // End of the function function init() { var temp = []; var temp = doc.firstChild.childNodes; scrollingList = []; var _l2 = 0; while (_l2<temp.length) { var tempList = temp[_l2].childNodes; var category = temp[_l2].attributes.category; var wordArray = []; var _l1 = 0; while (_l1<tempList.length) { var _l3 = tempList[_l1].firstChild.nodeValue; wordArray.push(_l3); _l1++; } // end while words.lists.push({wordList:wordArray, category:category}); scrollingList.push({label:category, data:_l2}); _l2++; } // end while scrollList.setDataProvider(scrollingList); scrollList.setChangeHandler("myHandler"); } // End of the function words = {}; words.lists = []; playButton._alpha = 50; init();