I am trying to pull a random string from my xml into a dynamic text field in Flash. In this example, the first text field should bring in a random fruit (Apple, Pear or Orange). Im stuck as to which way I should randomly do this. This is my code right now in my movieclip:
This is the xml which I am using:Code:var my_req:URLRequest=new URLRequest("articleInformation.xml"); //PUT IN YOUR XML SOURCE HERE var my_loader:URLLoader = new URLLoader(); var my_xml:XML; my_loader.addEventListener(Event.COMPLETE, xmlLoader); my_loader.load(my_req); function xmlLoader(event:Event):void { my_xml=new XML(my_loader.data); setupoutput_txt(); } function setupoutput_txt():void{ trace(my_xml.*); fruit_txt.text=String(my_xml.items.fruit.*); vegetable_txt.text=String(my_xml.boardDesc.*); furniture_txt.text=String(my_xml.boardColor.*); }
Code:<?xml version="1.0" encoding="utf-8"?> <list> <items> <fruit>Apple</fruit> <fruit>Pear</fruit> <fruit>Orange</fruit> </items> <boardDesc>blah blah blah</boardDesc> <boardColor>red</boardColor> </list>


Reply With Quote
