import flash.text.TextField;
//读取中文的xml配置文件
var myXML:XML = new XML();//创建一个新的XML类实例
var XML_URL:String = "text_main.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
//添加装载完成侦听器,
//Event.COMPLETE的值是"complete",直接用此字符串也可以。
myLoader.addEventListener(Event.COMPLETE, xmlLoaded);
var m_step:Number = 3;//每次移动距离
var _txt:TextField =new TextField();
function xmlLoaded(evtObj:Event):void
{
var v_text:String = "";
myXML = XML(myLoader.data);
//trace("数据装载完成.");
var nodeSize = myXML.children().length();
for (var i:int; i<nodeSize; i++)
{
v_text += "<a href='" + myXML.child(i).url.toString() + "'>" + myXML.child(i).name.toString() + "</a> ";
}
_txt.htmlText = v_text;
var format1:TextFormat=new TextFormat(null,24);
format1.font="黑体";
_txt.x = 0;
_txt.y = 0;
_txt.setTextFormat(format1);
_txt.textColor = 0xFF0000;
_txt.autoSize = TextFieldAutoSize.LEFT;
addChild(_txt);
//_txt.x = stage.stageWidth;
}
//文字移动
addEventListener(Event.ENTER_FRAME,enterFrameHanler);
function enterFrameHanler(e:Event)
{
_txt.x -= m_step;
//_txt.x += m_step;
if(_txt.x + _txt.width <0){
_txt.x = stage.stageWidth;
}
}
_txt.addEventListener(MouseEvent.MOUSE_OVER,moveHandle);
_txt.addEventListener(MouseEvent.MOUSE_OUT,outHandle);
function moveHandle(e:MouseEvent) {
e.updateAfterEvent();
removeEventListener(Event.ENTER_FRAME,enterFrameHanler);
}
function outHandle(e:MouseEvent){
e.updateAfterEvent();
addEventListener(Event.ENTER_FRAME,enterFrameHanler);
}
详细看CSDN资源,已经上传。
http://download.csdn.net/detail/hateson/3725692