我是actionscript3的新手,如果有人可以帮助我,我会有一个非常有用的问题。我正在尝试从rss feed xml文件中读取并在文本框中显示它并使框自动滚动的动作脚本,我的问题是文本字段不会循环回来。这是代码:
var RSSLoader:URLLoader = new URLLoader();
var RSSURL:URLRequest = new URLRequest("http://sports.yahoo.com/soccer//rss.xml");
RSSLoader.addEventListener(Event.COMPLETE, RSSLoaded);
RSSLoader.load(RSSURL);
stage.addEventListener(Event.ENTER_FRAME, TextScrollingFunction);
var RSSXML:XML = new XML();
RSSXML.ignoreWhitespace = true;
function RSSLoaded(e:Event):void
{
RSSXML = XML(RSSLoader.data);
//trace(RSSXML.toXMLString());
var title:TextField;
var desc:TextField;
var allText:TextField;
title = new TextField();
allText = new TextField();
for(var selectedItems:String in RSSXML.channel.item){
title.text=(RSSXML.channel.item[selectedItems].title+"\n");
title.wordWrap = true;
tfLog.text+=title.text;
tfLog.wordWrap = true;
trace(title.text);
}
function TextScrollingFunction(evt:Event)
{
tfLog.x+=3;//the Speed of the srolling Text
if ((tfLog.x + tfLog.width)<0) {
tfLog.x=stage.stageWidth;
//remove all the Children from the stage.
while (tfLog.numChildren > 0) {
tfLog.removeChildAt(0);
}
RSSLoader.load(RSSURL);
}
答案 0 :(得分:0)
如果每个装载机工作正常,我想说问题可能是:
...
if (tfLog.x > stage.stageWidth) {
tfLog.x = -tfLog.width; //but in case your textfield has a static width
...
或者简单地说:
...
tfLog.x -= 3;
...