FocusEvent.MOUSE_FOCUS_CHANGE : Focus Event : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » Focus Event »

 

FocusEvent.MOUSE_FOCUS_CHANGE


 

package
{
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.events.FocusEvent;

    public class Main extends Sprite
    {
        public function Main()
        {
            var tf1:TextField = new TextField();
            tf1.type = "input";
            tf1.height = 20;
            tf1.width = 100;
            tf1.border = true;

            addChild(tf1);
            tf1.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, checkFocus);

            var tf2:TextField = new TextField();
            tf2.type = "input";
            tf2.height = 20;
            tf2.width = 100;
            tf2.border = true;
            addChild(tf2);
            tf2.x = 200;
        }

        private function checkFocus(focusEvent:FocusEvent):void
        {
            if ((focusEvent.target as TextField).text == "")
            {
                focusEvent.preventDefault();
            }
        }
    }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Development
» Focus Event