我编写了以下代码 (AS3),它加载 XLM 文件,获取星期几,然后在舞台上显示相应的问题。
当我在 Flash 中测试时,它在我的计算机上运行良好。但在我的 Galaxy S2 上,它只显示安装当天的问题,并且不会每天更新一个新问题。
我在这里想念什么?提前致谢。
这是 XML:
<?xml version="1.0" encoding="UTF-8"?>
<questions7>
<question day="0"><![CDATA[Question for Sunday ]]></question>
<question day="1"><![CDATA[Question for Monday ]]></question>
<question day="2"><![CDATA[Question for Tuesday ]]></question>
<question day="3"><![CDATA[Question for Wednesday ]]></question>
<question day="4"><![CDATA[Question for Thursday ]]></question>
<question day="5"><![CDATA[Question for Friday ]]></question>
<question day="6"><![CDATA[Question for Saturday ]]></question>
</questions7>
和动作脚本:
//Loads external XML file
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("questions7.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
// Get day number of the week
var myDateDay:Date = new Date();
var dayNumber:int = myDateDay.day;
//To display question of the day
function processXML(e:Event):void {
myXML = new XML(e.target.data);
var question:XMLList = myXML.question.(@day == dayNumber);
trace(question);
var myText1:TextField = new TextField();
myText1.text = question;
myText1.autoSize = TextFieldAutoSize.CENTER;
myText1.border = false;
myText1.width = stage.stageWidth - 100;
myText1.multiline = true;
myText1.wordWrap = true;
myText1.y = 200;
myText1.x = 50;
// Add to stage
addChild(myText1);
}