0
我有一个健康提示Flash动画,我想每天显示一个提示。 我创建了一个xml,每天365项。现在我想用xml链接我的闪光灯,以获得特定日期的正确提示。根据日期通过flash调用XML项目
我用两种方法创建了XML ..你认为哪一个最好?
<data>
<Tip date="28/03/2012" title="Start your day with breakfast." description="Breakfast fills your empty tank to get you going after a long night without food. "/>
</data>
而另一个XML
<data>
<title name="Start your day with breakfast.">
<description>Breakfast fills your "empty tank" to get you going after a long night without food. </description>
</title>
<title name="Eat more grains, fruits and vegetables.">
<description>These foods give you carbohydrates for energy, plus vitamins, minerals and fiber. Besides, they taste good! Try breads such as whole-wheat, bagels and pita. </description>
</title>
</data>
现在我需要编写我的Flash影片得到它的工作,但不幸的是不知道怎么办。
我开始与一些基本的东西:
var my_date:Date = new Date();
var months:Array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
var dateStr = ((months[my_date.month]).toString())+"_"+ my_date.date.toString()+"_"+ my_date.fullYear.toString();
//Create the loader, set dataFormat to text
var loadFile:URLLoader = new URLLoader()
loadFile.dataFormat = URLLoaderDataFormat.TEXT
loadFile.addEventListener(Event.COMPLETE, onLoadXML)
loadFile.load(new URLRequest("flash1.xml"));
function onLoadXML(ev:Event){
try{
//Convert the downloaded text into an XML
var myXML:XML = new XML(ev.target.data)
var list:XMLList = myXML..title
//walks the list and show in textfields
for(var i=0; i<list.length(); i++){
//trace(list[i][email protected]+"-"+list[i].comments+" - "+list[i].image)
this["Title_txt"+i].text = [email protected]
this["description_txt"+i].text = list.description
}
} catch (e:TypeError){
//Could not convert the data
trace("Could not parse the XML")
trace(e.message)
}
}
我不能让它正常工作,从而寻求帮助。如果你请帮我解决日期问题,as3代码会很棒。
谢谢你,等待你的回答
海伦
谢谢你的回答......这使得它在某种程度上更简单的...虽然我仍然有日期功能的问题加载特定日期 – 2012-03-28 12:04:45
好了,你的代码显示,你甚至不尝试做日期的事情。我不知道你想用“日期函数”来做什么。你为什么不详细说明? – 2012-03-28 16:42:22