[as3]TextField,鼠标经过文本变色

      flash学习 2006-10-16 18:52
//---------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)
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commenttime}{commentauthor}

{CommentUrl}
{commentcontent}