TextField, the mouse changes color after the text

Source: Internet
Author: User

TextField, the mouse changes color after the text // --------- code by ycccc8202 ----------
Var myText: TextField = new TextField ()
MyText. text = "There have been many successive mistakes on the highway of life"
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); // continuously retrieve the character index at the specified position
If (charIndex =-1) {// if the mouse moves out of the text
Return ;}
MyText. setTextFormat (myTextFormat_new, charIndex, charIndex + 1 );
    }

AddEventListener (Event. ENTER_FRAME, enterFrameListener); // registers a listener loop Event
AddChild (myText)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.