将xml和as3数据导入数组和按钮进行导航

时间:2014-01-02 13:39:50

标签: xml arrays actionscript-3

我有一个保存数据的xml文件,我的fla文件调用数据。我有3个按钮(景点,酒吧和餐馆),我有景点按钮只调用景点数据项。我已经为flash中调用的数据创建了动态文本字段(name_Text.text = myXML.attractions.place.name [0];),但Id喜欢在检索数据时将数据放入数组中,以便单击下一个/后退按钮时,用户可以在每个节点之间导航。在这件事上,我们将非常感谢您的帮助。

另外,我似乎无法显示图像,我只能导入图像的名称,为什么会发生这种情况?

function xmlLoaded(event:Event):void 
{ 
   myXML = XML(myLoader.data);

   var xmlDoc:XMLDocument = new XMLDocument();
    // Ignore spacing around nodes
    xmlDoc.ignoreWhite = true;
    //initialize menuXML
    var menuXML:XML = XML(myLoader.data);
    // Parse the XML data into a readable format
    xmlDoc.parseXML(menuXML.toXMLString());
    //initialize i
    var count:Number = 0;
// Run the "for each" loop to iterate through all of the menu items listed in the external XML file
for each (var attractions:XML in myXML..attractions.place) {

   name_Text.text = myXML.attractions.place.name[0];
   info_Text.text = myXML.attractions.place.info[0];
   thumbnail_Text.text = myXML.attractions.place.thumbnail[0];
   thumbnail_Title_Text.text = myXML.attractions.place.thumbTitle[0];
   image_Text.text = myXML.attractions.place.image[0];
   address_Text.text = myXML.attractions.place.address[0];
   web_Text.text = myXML.attractions.place.web[0];

   count++;
   trace(count);
   }

}  

0 个答案:

没有答案