Mega Code Archive

 
Categories / Flash ActionScript / TextField
 

Retrieving Strings from a TextField

package {     import flash.text.TextField;     import flash.events.MouseEvent;     import flash.display.Sprite;          public class WidthHeightTest extends Sprite     {        private var txt:TextField;        public function WidthHeightTest()        {                   txt = new TextField();              txt.autoSize = "left";              addChild(txt);              txt.text = "conductor.";              txt.addEventListener(MouseEvent.MOUSE_MOVE, getTextUnderMouse);        }             private function getTextUnderMouse(mouseEvent:MouseEvent):void        {              var charInt:int = txt.getCharIndexAtPoint(mouseEvent.stageX, mouseEvent.stageY);              trace(txt.text.charAt(charInt));        }     } }