【www.gdgbn.com--ios】

TextField的,鼠标经过文本变色//---------code by ycccc8202----------
var myText:TextField=new TextField()
myText.text="在人生的高速路上已经连续转错了不少弯"
myText.width=myText.height=300
myText.x=myText.y=100
var myTextFormat_old=new TextFormat()
myTextFormat_old.color="0x000000"
myTextFormat_old.size=12
var myTextFormat_new=new TextFormat()
myTextFormat_new.color="0xff0000"
myTextFormat_new.size=24
function enterFrameListener(event:Event) {
myText.setTextFormat(myTextFormat_old);
      var charIndex:int = myText.getCharIndexAtPoint(myText.mouseX,myText.mouseY);//不断取得指定位置的字符索引
     if(charIndex==-1){//如果鼠标移出文本
                return;}
          myText.setTextFormat(myTextFormat_new,charIndex,charIndex+1);
    }

addEventListener(Event.ENTER_FRAME, enterFrameListener);//注册桢循环事件
addChild(myText)

本文来源:http://www.gdgbn.com/shoujikaifa/15718/